@@ -356,13 +356,20 @@ nthtail_1(N, [_|T]) ->
356
356
-doc """
357
357
Returns `true` if `List1` is a prefix of `List2`; otherwise, returns `false`.
358
358
359
+ A prefix of a list is the first part of the list, starting from the
360
+ beginning and stopping at any point.
361
+
359
362
## Examples
360
363
361
364
```erlang
362
365
> lists:prefix("abc", "abcdef").
363
366
true
364
367
> lists:prefix("def", "abcdef").
365
368
false
369
+ > lists:prefix([], "any list").
370
+ true
371
+ > lists:prefix("abc", "abc").
372
+ true
366
373
```
367
374
""" .
368
375
-spec prefix (List1 , List2 ) -> boolean () when
@@ -378,13 +385,20 @@ prefix([_|_], List) when is_list(List) -> false.
378
385
-doc """
379
386
Returns `true` if `List1` is a suffix of `List2`; otherwise, returns `false`.
380
387
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
+
381
391
## Examples
382
392
383
393
```erlang
384
394
> lists:suffix("abc", "abcdef").
385
395
false
386
396
> lists:suffix("def", "abcdef").
387
397
true
398
+ > lists:suffix([], "any list").
399
+ true
400
+ > lists:suffix("abc", "abc").
401
+ true
388
402
```
389
403
""" .
390
404
-spec suffix (List1 , List2 ) -> boolean () when
@@ -1028,6 +1042,8 @@ zipwith3(F, [X | Xs], [Y | Ys], [], {pad, {_, _, Z}} = How) ->
1028
1042
-doc """
1029
1043
Returns a list containing the sorted elements of `List1`.
1030
1044
1045
+ The sort is stable.
1046
+
1031
1047
## Examples
1032
1048
1033
1049
```erlang
@@ -1036,6 +1052,15 @@ Returns a list containing the sorted elements of `List1`.
1036
1052
> lists:sort([a,4,3,b,9]).
1037
1053
[3,4,9,a,b]
1038
1054
```
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
+ ```
1039
1064
""" .
1040
1065
-spec sort (List1 ) -> List2 when
1041
1066
List1 :: [T ],
@@ -2022,6 +2047,10 @@ first occurrence of elements that compare equal.
2022
2047
[a,b,c,x,y]
2023
2048
> lists:usort([3,2,a,3,2,a,1,3,b,2,2,1]).
2024
2049
[1,2,3,a,b]
2050
+ > lists:usort([1.0,1]).
2051
+ [1.0]
2052
+ > lists:usort([1,1.0]).
2053
+ [1]
2025
2054
```
2026
2055
""" .
2027
2056
-spec usort (List1 ) -> List2 when
0 commit comments