Skip to content

Commit 2455cff

Browse files
committed
fixup! Polish documentation for the lists modules
1 parent 19d556f commit 2455cff

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

lib/stdlib/src/lists.erl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,20 @@ nthtail_1(N, [_|T]) ->
356356
-doc """
357357
Returns `true` if `List1` is a prefix of `List2`; otherwise, returns `false`.
358358

359+
A prefix of a list is the first part of the list, starting from the
360+
beginning and stopping at any point.
361+
359362
## Examples
360363

361364
```erlang
362365
> lists:prefix("abc", "abcdef").
363366
true
364367
> lists:prefix("def", "abcdef").
365368
false
369+
> lists:prefix([], "any list").
370+
true
371+
> lists:prefix("abc", "abc").
372+
true
366373
```
367374
""".
368375
-spec prefix(List1, List2) -> boolean() when
@@ -378,13 +385,20 @@ prefix([_|_], List) when is_list(List) -> false.
378385
-doc """
379386
Returns `true` if `List1` is a suffix of `List2`; otherwise, returns `false`.
380387

388+
A suffix of a list is the last part of the list, starting from any position
389+
and going all the way to the end.
390+
381391
## Examples
382392

383393
```erlang
384394
> lists:suffix("abc", "abcdef").
385395
false
386396
> lists:suffix("def", "abcdef").
387397
true
398+
> lists:suffix([], "any list").
399+
true
400+
> lists:suffix("abc", "abc").
401+
true
388402
```
389403
""".
390404
-spec suffix(List1, List2) -> boolean() when
@@ -1028,6 +1042,8 @@ zipwith3(F, [X | Xs], [Y | Ys], [], {pad, {_, _, Z}} = How) ->
10281042
-doc """
10291043
Returns a list containing the sorted elements of `List1`.
10301044

1045+
The sort is stable.
1046+
10311047
## Examples
10321048

10331049
```erlang
@@ -1036,6 +1052,15 @@ Returns a list containing the sorted elements of `List1`.
10361052
> lists:sort([a,4,3,b,9]).
10371053
[3,4,9,a,b]
10381054
```
1055+
Since the sort is stable, the relative order of elements that compare
1056+
equal is not changed:
1057+
1058+
```erlang
1059+
> lists:sort([1.0,1]).
1060+
[1.0,1]
1061+
> lists:sort([1,1.0]).
1062+
[1,1.0]
1063+
```
10391064
""".
10401065
-spec sort(List1) -> List2 when
10411066
List1 :: [T],
@@ -2022,6 +2047,10 @@ first occurrence of elements that compare equal.
20222047
[a,b,c,x,y]
20232048
> lists:usort([3,2,a,3,2,a,1,3,b,2,2,1]).
20242049
[1,2,3,a,b]
2050+
> lists:usort([1.0,1]).
2051+
[1.0]
2052+
> lists:usort([1,1.0]).
2053+
[1]
20252054
```
20262055
""".
20272056
-spec usort(List1) -> List2 when

0 commit comments

Comments
 (0)