From 229d0d8ca88bc344bed89e46541b325c1d267996 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Fri, 6 May 2011 15:58:09 +0200 Subject: r Use Erlang specs and types for documentation --- lib/stdlib/doc/src/lists.xml | 764 ++++++++++++++----------------------------- 1 file changed, 238 insertions(+), 526 deletions(-) (limited to 'lib/stdlib/doc/src/lists.xml') diff --git a/lib/stdlib/doc/src/lists.xml b/lib/stdlib/doc/src/lists.xml index 92c4eb4f4c..6f3ed7af98 100644 --- a/lib/stdlib/doc/src/lists.xml +++ b/lib/stdlib/doc/src/lists.xml @@ -4,7 +4,7 @@
- 19962010 + 19962011 Ericsson AB. All Rights Reserved. @@ -60,58 +60,41 @@ - all(Pred, List) -> bool() + Return true if all elements in the list satisfyPred - - Pred = fun(Elem) -> bool() -  Elem = term() - List = [term()] - -

Returns true if Pred(Elem) returns - true for all elements Elem in List, +

Returns true if Pred(Elem) returns + true for all elements Elem in List, otherwise false.

- any(Pred, List) -> bool() + Return true if any of the elements in the list satisfiesPred - - Pred = fun(Elem) -> bool() -  Elem = term() - List = [term()] - -

Returns true if Pred(Elem) returns - true for at least one element Elem in - List.

+

Returns true if Pred(Elem) returns + true for at least one element Elem in + List.

- append(ListOfLists) -> List1 + Append a list of lists - - ListOfLists = [List] - List = List1 = [term()] -

Returns a list in which all the sub-lists of - ListOfLists have been appended. For example:

+ ListOfLists have been appended. For example:

 > lists:append([[1, 2, 3], [a, b], [4, 5, 6]]).
 [1,2,3,a,b,4,5,6]
- append(List1, List2) -> List3 + Append two lists - - List1 = List2 = List3 = [term()] - -

Returns a new list List3 which is made from - the elements of List1 followed by the elements of - List2. For example:

+

Returns a new list List3 which is made from + the elements of List1 followed by the elements of + List2. For example:

 > lists:append("abc", "def").
 "abcdef"
@@ -119,15 +102,11 @@
- concat(Things) -> string() + Concatenate a list of atoms - - Things = [Thing] -  Thing = atom() | integer() | float() | string() -

Concatenates the text representation of the elements - of Things. The elements of Things can be atoms, + of Things. The elements of Things can be atoms, integers, floats or strings.

 > lists:concat([doc, '/', file, '.', 3]).
@@ -135,87 +114,59 @@
       
     
     
-      delete(Elem, List1) -> List2
+      
       Delete an element from a list
-      
-        Elem = term()
-        List1 = List2 = [term()]
-      
       
-        

Returns a copy of List1 where the first element - matching Elem is deleted, if there is such an +

Returns a copy of List1 where the first element + matching Elem is deleted, if there is such an element.

- dropwhile(Pred, List1) -> List2 + Drop elements from a list while a predicate is true - - Pred = fun(Elem) -> bool() -  Elem = term() - List1 = List2 = [term()] - -

Drops elements Elem from List1 while - Pred(Elem) returns true and returns +

Drops elements Elem from List1 while + Pred(Elem) returns true and returns the remaining list.

- duplicate(N, Elem) -> List + Make N copies of element - - N = int() - Elem = term() - List = [term()] - -

Returns a list which contains N copies of the term - Elem. For example:

+

Returns a list which contains N copies of the term + Elem. For example:

 > lists:duplicate(5, xx).
 [xx,xx,xx,xx,xx]
- filter(Pred, List1) -> List2 + Choose elements which satisfy a predicate - - Pred = fun(Elem) -> bool() -  Elem = term() - List1 = List2 = [term()] - -

List2 is a list of all elements Elem in - List1 for which Pred(Elem) returns +

List2 is a list of all elements Elem in + List1 for which Pred(Elem) returns true.

- flatlength(DeepList) -> int() + Length of flattened deep list - - DeepList = [term() | DeepList] - -

Equivalent to length(flatten(DeepList)), but more +

Equivalent to length(flatten(DeepList)), but more efficient.

- flatmap(Fun, List1) -> List2 + Map and flatten in one pass - - Fun = fun(A) -> [B] - List1 = [A] - List2 = [B] -  A = B = term() - -

Takes a function from As to lists of Bs, and a - list of As (List1) and produces a list of - Bs by applying the function to every element in - List1 and appending the resulting lists.

+

Takes a function from As to lists of Bs, and a + list of As (List1) and produces a list of + Bs by applying the function to every element in + List1 and appending the resulting lists.

That is, flatmap behaves as if it had been defined as follows:

@@ -228,43 +179,29 @@ flatmap(Fun, List1) ->
- flatten(DeepList) -> List + Flatten a deep list - - DeepList = [term() | DeepList] - List = [term()] - -

Returns a flattened version of DeepList.

+

Returns a flattened version of DeepList.

- flatten(DeepList, Tail) -> List + Flatten a deep list - - DeepList = [term() | DeepList] - Tail = List = [term()] - -

Returns a flattened version of DeepList with the tail - Tail appended.

+

Returns a flattened version of DeepList with the tail + Tail appended.

- foldl(Fun, Acc0, List) -> Acc1 + Fold a function over a list - - Fun = fun(Elem, AccIn) -> AccOut -  Elem = term() - Acc0 = Acc1 = AccIn = AccOut = term() - List = [term()] - -

Calls Fun(Elem, AccIn) on successive elements A - of List, starting with AccIn == Acc0. - Fun/2 must return a new accumulator which is passed to +

Calls Fun(Elem, AccIn) on successive elements A + of List, starting with AccIn == Acc0. + Fun/2 must return a new accumulator which is passed to the next call. The function returns the final value of - the accumulator. Acc0 is returned if the list is empty. + the accumulator. Acc0 is returned if the list is empty. For example:

 > lists:foldl(fun(X, Sum) -> X + Sum end, 0, [1,2,3,4,5]).
@@ -274,14 +211,8 @@ flatmap(Fun, List1) ->
       
     
     
-      foldr(Fun, Acc0, List) -> Acc1
+      
       Fold a function over a list
-      
-        Fun = fun(Elem, AccIn) -> AccOut
-         Elem = term()
-        Acc0 = Acc1 = AccIn = AccOut = term()
-        List = [term()]
-      
       
         

Like foldl/3, but the list is traversed from right to left. For example:

@@ -297,33 +228,23 @@ flatmap(Fun, List1) ->
- foreach(Fun, List) -> void() + Apply a function to each element of a list - - Fun = fun(Elem) -> void() -  Elem = term() - List = [term()] - -

Calls Fun(Elem) for each element Elem in - List. This function is used for its side effects and +

Calls Fun(Elem) for each element Elem in + List. This function is used for its side effects and the evaluation order is defined to be the same as the order of the elements in the list.

- keydelete(Key, N, TupleList1) -> TupleList2 + Delete an element from a list of tuples - - Key = term() - N = 1..tuple_size(Tuple) - TupleList1 = TupleList2 = [Tuple] -  Tuple = tuple() - + 1..tuple_size(Tuple) -

Returns a copy of TupleList1 where the first - occurrence of a tuple whose Nth element compares equal to - Key is deleted, if there is such a tuple.

+

Returns a copy of TupleList1 where the first + occurrence of a tuple whose Nth element compares equal to + Key is deleted, if there is such a tuple.

@@ -343,19 +264,14 @@ flatmap(Fun, List1) -> - keymap(Fun, N, TupleList1) -> TupleList2 + Map a function over a list of tuples - - Fun = fun(Term1) -> Term2 -  Term1 = Term2 = term() - N = 1..tuple_size(Tuple) - TupleList1 = TupleList2 = [tuple()] - + 1..tuple_size(Tuple)

Returns a list of tuples where, for each tuple in - TupleList1, the Nth element Term1 of the tuple + TupleList1, the Nth element Term1 of the tuple has been replaced with the result of calling - Fun(Term1).

+ Fun(Term1).

Examples:

 > Fun = fun(Atom) -> atom_to_list(Atom) end.
@@ -365,7 +281,7 @@ flatmap(Fun, List1) ->
       
     
     
-      keymember(Key, N, TupleList) -> bool()
+      keymember(Key, N, TupleList) -> boolean()
       Test for membership of a list of tuples
       
         Key = term()
@@ -380,37 +296,28 @@ flatmap(Fun, List1) ->
       
     
     
-      keymerge(N, TupleList1, TupleList2) -> TupleList3
+      
       Merge two key-sorted lists of tuples
-      
-        N = 1..tuple_size(Tuple)
-        TupleList1 = TupleList2 = TupleList3 = [Tuple]
-         Tuple = tuple()
-      
+      1..tuple_size(Tuple)
       
-        

Returns the sorted list formed by merging TupleList1 - and TupleList2. The merge is performed on - the Nth element of each tuple. Both TupleList1 and - TupleList2 must be key-sorted prior to evaluating this +

Returns the sorted list formed by merging TupleList1 + and TupleList2. The merge is performed on + the Nth element of each tuple. Both TupleList1 and + TupleList2 must be key-sorted prior to evaluating this function. When two tuples compare equal, the tuple from - TupleList1 is picked before the tuple from - TupleList2.

+ TupleList1 is picked before the tuple from + TupleList2.

- keyreplace(Key, N, TupleList1, NewTuple) -> TupleList2 + Replace an element in a list of tuples - - Key = term() - N = 1..tuple_size(Tuple) - TupleList1 = TupleList2 = [Tuple] - NewTuple = Tuple = tuple() - + 1..tuple_size(Tuple) -

Returns a copy of TupleList1 where the first - occurrence of a T tuple whose Nth element - compares equal to Key is replaced with - NewTuple, if there is such a tuple T.

+

Returns a copy of TupleList1 where the first + occurrence of a T tuple whose Nth element + compares equal to Key is replaced with + NewTuple, if there is such a tuple T.

@@ -433,95 +340,63 @@ flatmap(Fun, List1) -> - keysort(N, TupleList1) -> TupleList2 + Sort a list of tuples - - N = 1..tuple_size(Tuple) - TupleList1 = TupleList2 = [Tuple] -  Tuple = tuple() - + 1..tuple_size(Tuple)

Returns a list containing the sorted elements of the list - TupleList1. Sorting is performed on the Nth + TupleList1. Sorting is performed on the Nth element of the tuples. The sort is stable.

- keystore(Key, N, TupleList1, NewTuple) -> TupleList2 + Store an element in a list of tuples - - Key = term() - N = 1..tuple_size(Tuple) - TupleList1 = TupleList2 = [Tuple] - NewTuple = Tuple = tuple() - - -

Returns a copy of TupleList1 where the first - occurrence of a tuple T whose Nth element - compares equal to Key is replaced with - NewTuple, if there is such a tuple T. If there - is no such tuple T a copy of TupleList1 where - [NewTuple] has been appended to the end is + 1..tuple_size(Tuple) + +

Returns a copy of TupleList1 where the first + occurrence of a tuple T whose Nth element + compares equal to Key is replaced with + NewTuple, if there is such a tuple T. If there + is no such tuple T a copy of TupleList1 where + [NewTuple] has been appended to the end is returned.

- keytake(Key, N, TupleList1) -> {value, Tuple, TupleList2} - | false + Extract an element from a list of tuples - - Key = term() - N = 1..tuple_size(Tuple) - TupleList1 = TupleList2 = [Tuple] - Tuple = tuple() - + 1..tuple_size(Tuple) -

Searches the list of tuples TupleList1 for a tuple - whose Nth element compares equal to Key. - Returns {value, Tuple, TupleList2} if such a tuple is - found, otherwise false. TupleList2 is a copy - of TupleList1 where the first occurrence of - Tuple has been removed.

+

Searches the list of tuples TupleList1 for a tuple + whose Nth element compares equal to Key. + Returns {value, Tuple, TupleList2} if such a tuple is + found, otherwise false. TupleList2 is a copy + of TupleList1 where the first occurrence of + Tuple has been removed.

- last(List) -> Last + Return last element in a list - - List = [term()], length(List) > 0 - Last = term() - -

Returns the last element in List.

+

Returns the last element in List.

- map(Fun, List1) -> List2 + Map a function over a list - - Fun = fun(A) -> B - List1 = [A] - List2 = [B] -  A = B = term() - -

Takes a function from As to Bs, and a list of - As and produces a list of Bs by applying +

Takes a function from As to Bs, and a list of + As and produces a list of Bs by applying the function to every element in the list. This function is used to obtain the return values. The evaluation order is implementation dependent.

- mapfoldl(Fun, Acc0, List1) -> {List2, Acc1} + Map and fold in one pass - - Fun = fun(A, AccIn) -> {B, AccOut} - Acc0 = Acc1 = AccIn = AccOut = term() - List1 = [A] - List2 = [B] -  A = B = term() -

mapfoldl combines the operations of map/2 and foldl/3 into one pass. An example, summing @@ -533,35 +408,24 @@ flatmap(Fun, List1) -> - mapfoldr(Fun, Acc0, List1) -> {List2, Acc1} + Map and fold in one pass - - Fun = fun(A, AccIn) -> {B, AccOut} - Acc0 = Acc1 = AccIn = AccOut = term() - List1 = [A] - List2 = [B] -  A = B = term() -

mapfoldr combines the operations of map/2 and foldr/3 into one pass.

- max(List) -> Max + Return maximum element of a list - - List = [term()], length(List) > 0 - Max = term() - -

Returns the first element of List that compares +

Returns the first element of List that compares greater than or equal to all other elements of - List.

+ List.

- member(Elem, List) -> bool() + member(Elem, List) -> boolean() Test for membership of a list Elem = term() @@ -573,112 +437,84 @@ flatmap(Fun, List1) -> - merge(ListOfLists) -> List1 + Merge a list of sorted lists - - ListOfLists = [List] - List = List1 = [term()] -

Returns the sorted list formed by merging all the sub-lists - of ListOfLists. All sub-lists must be sorted prior to + of ListOfLists. All sub-lists must be sorted prior to evaluating this function. When two elements compare equal, the element from the sub-list with the lowest position in - ListOfLists is picked before the other element.

+ ListOfLists is picked before the other element.

- merge(List1, List2) -> List3 + Merge two sorted lists - - List1 = List2 = List3 = [term()] - -

Returns the sorted list formed by merging List1 and - List2. Both List1 and List2 must be +

Returns the sorted list formed by merging List1 and + List2. Both List1 and List2 must be sorted prior to evaluating this function. When two elements - compare equal, the element from List1 is picked - before the element from List2.

+ compare equal, the element from List1 is picked + before the element from List2.

- merge(Fun, List1, List2) -> List3 + Merge two sorted list - - Fun = fun(A, B) -> bool() - List1 = [A] - List2 = [B] - List3 = [A | B] -  A = B = term() - -

Returns the sorted list formed by merging List1 and - List2. Both List1 and List2 must be +

Returns the sorted list formed by merging List1 and + List2. Both List1 and List2 must be sorted according to the ordering function - Fun prior to evaluating this function. Fun(A, - B) should return true if A compares less - than or equal to B in the ordering, false + Fun prior to evaluating this function. Fun(A, + B) should return true if A compares less + than or equal to B in the ordering, false otherwise. When two elements compare equal, the element from - List1 is picked before the element from - List2.

+ List1 is picked before the element from + List2.

- merge3(List1, List2, List3) -> List4 + Merge three sorted lists - - List1 = List2 = List3 = List4 = [term()] - -

Returns the sorted list formed by merging List1, - List2 and List3. All of List1, - List2 and List3 must be sorted prior to +

Returns the sorted list formed by merging List1, + List2 and List3. All of List1, + List2 and List3 must be sorted prior to evaluating this function. When two elements compare equal, - the element from List1, if there is such an element, + the element from List1, if there is such an element, is picked before the other element, otherwise the element - from List2 is picked before the element from - List3.

+ from List2 is picked before the element from + List3.

- min(List) -> Min + Return minimum element of a list - - List = [term()], length(List) > 0 - Min = term() - -

Returns the first element of List that compares +

Returns the first element of List that compares less than or equal to all other elements of - List.

+ List.

- nth(N, List) -> Elem + Return the Nth element of a list - - N = 1..length(List) - List = [term()] - Elem = term() - + 1..length(List) -

Returns the Nth element of List. For example:

+

Returns the Nth element of List. For example:

 > lists:nth(3, [a, b, c, d, e]).
 c
- nthtail(N, List1) -> Tail + Return the Nth tail of a list - - N = 0..length(List1) - List1 = Tail = [term()] - + 0..length(List) -

Returns the Nth tail of List, that is, the sublist of - List starting at N+1 and continuing up to +

Returns the Nth tail of List, that is, the sublist of + List starting at N+1 and continuing up to the end of the list. For example:

 > lists:nthtail(3, [a, b, c, d, e]).
@@ -692,18 +528,13 @@ c
- partition(Pred, List) -> {Satisfying, NonSatisfying} + Partition a list into two lists based on a predicate - - Pred = fun(Elem) -> bool() -  Elem = term() - List = Satisfying = NonSatisfying = [term()] - -

Partitions List into two lists, where the first list - contains all elements for which Pred(Elem) returns +

Partitions List into two lists, where the first list + contains all elements for which Pred(Elem) returns true, and the second list contains all elements for - which Pred(Elem) returns false.

+ which Pred(Elem) returns false.

Examples:

 > lists:partition(fun(A) -> A rem 2 == 1 end, [1,2,3,4,5,6,7]).
@@ -715,24 +546,18 @@ c
- prefix(List1, List2) -> bool() + Test for list prefix - - List1 = List2 = [term()] - -

Returns true if List1 is a prefix of - List2, otherwise false.

+

Returns true if List1 is a prefix of + List2, otherwise false.

- reverse(List1) -> List2 + Reverse a list - - List1 = List2 = [term()] - -

Returns a list with the top level elements in List1 +

Returns a list with the elements in List1 in reverse order.

@@ -743,7 +568,7 @@ c
List1 = Tail = List2 = [term()] -

Returns a list with the top level elements in List1 +

Returns a list with the elements in List1 in reverse order, with the tail Tail appended. For example:

@@ -752,22 +577,18 @@ c
- seq(From, To) -> Seq - seq(From, To, Incr) -> Seq + + Generate a sequence of integers - - From = To = Incr = int() - Seq = [int()] - -

Returns a sequence of integers which starts with From - and contains the successive results of adding Incr to - the previous element, until To has been reached or - passed (in the latter case, To is not an element of - the sequence). Incr defaults to 1.

-

Failure: If and Incr - is positive, or if To>From-Incr and Incr is - negative, or if Incr==0 and From/=To.

+

Returns a sequence of integers which starts with From + and contains the successive results of adding Incr to + the previous element, until To has been reached or + passed (in the latter case, To is not an element of + the sequence). Incr defaults to 1.

+

Failure: If To<From-Incr and Incr + is positive, or if To>From-Incr and Incr is + negative, or if Incr==0 and From/=To.

The following equalities hold for all sequences:

length(lists:seq(From, To)) == To-From+1 @@ -787,57 +608,41 @@ length(lists:seq(From, To, Incr)) == (To-From+Incr) div Incr
- sort(List1) -> List2 + Sort a list - - List1 = List2 = [term()] -

Returns a list containing the sorted elements of - List1.

+ List1.

- sort(Fun, List1) -> List2 + Sort a list - - Fun = fun(Elem1, Elem2) -> bool() -  Elem1 = Elem2 = term() - List1 = List2 = [term()] -

Returns a list containing the sorted elements of - List1, according to the List1, according to the ordering function - Fun. Fun(A, B) should return true if - A compares less than or equal to B in the + Fun. Fun(A, B) should return true if + A compares less than or equal to B in the ordering, false otherwise.

- split(N, List1) -> {List2, List3} + Split a list into two lists - - N = 0..length(List1) - List1 = List2 = List3 = [term()] - + 0..length(List1) -

Splits List1 into List2 and List3. - List2 contains the first N elements and - List3 the rest of the elements (the Nth tail).

+

Splits List1 into List2 and List3. + List2 contains the first N elements and + List3 the rest of the elements (the Nth tail).

- splitwith(Pred, List) -> {List1, List2} + Split a list into two lists based on a predicate - - Pred = fun(Elem) -> bool() -  Elem = term() - List = List1 = List2 = [term()] - -

Partitions List into two lists according to - Pred. splitwith/2 behaves as if it is defined +

Partitions List into two lists according to + Pred. splitwith/2 behaves as if it is defined as follows:

splitwith(Pred, List) -> @@ -853,31 +658,23 @@ splitwith(Pred, List) ->
- sublist(List1, Len) -> List2 + Return a sub-list of a certain length, starting at the first position - - List1 = List2 = [term()] - Len = int() - -

Returns the sub-list of List1 starting at position 1 - and with (max) Len elements. It is not an error for - Len to exceed the length of the list -- in that case +

Returns the sub-list of List1 starting at position 1 + and with (max) Len elements. It is not an error for + Len to exceed the length of the list -- in that case the whole list is returned.

- sublist(List1, Start, Len) -> List2 + Return a sub-list starting at a given position and with a given number of elements - - List1 = List2 = [term()] - Start = 1..(length(List1)+1) - Len = int() - + 1..(length(List1)+1) -

Returns the sub-list of List1 starting at Start - and with (max) Len elements. It is not an error for - Start+Len to exceed the length of the list.

+

Returns the sub-list of List1 starting at Start + and with (max) Len elements. It is not an error for + Start+Len to exceed the length of the list.

 > lists:sublist([1,2,3,4], 2, 2).
 [2,3]
@@ -888,15 +685,12 @@ splitwith(Pred, List) ->
       
     
     
-      subtract(List1, List2) -> List3
+      
       Subtract the element in one list from another list
-      
-        List1 = List2 = List3 = [term()]
-      
       
-        

Returns a new list List3 which is a copy of - List1, subjected to the following procedure: for each - element in List2, its first occurrence in List1 +

Returns a new list List3 which is a copy of + List1, subjected to the following procedure: for each + element in List2, its first occurrence in List1 is deleted. For example:

 > lists:subtract("123212", "212").
@@ -911,151 +705,112 @@ splitwith(Pred, List) ->
       
     
     
-      suffix(List1, List2) -> bool()
+      
       Test for list suffix
       
-        

Returns true if List1 is a suffix of - List2, otherwise false.

+

Returns true if List1 is a suffix of + List2, otherwise false.

- sum(List) -> number() + Return sum of elements in a list - - List = [number()] - -

Returns the sum of the elements in List.

+

Returns the sum of the elements in List.

- takewhile(Pred, List1) -> List2 + Take elements from a list while a predicate is true - - Pred = fun(Elem) -> bool() -  Elem = term() - List1 = List2 = [term()] - -

Takes elements Elem from List1 while - Pred(Elem) returns true, that is, +

Takes elements Elem from List1 while + Pred(Elem) returns true, that is, the function returns the longest prefix of the list for which all elements satisfy the predicate.

- ukeymerge(N, TupleList1, TupleList2) -> TupleList3 + Merge two key-sorted lists of tuples, removing duplicates - - N = 1..tuple_size(Tuple) - TupleList1 = TupleList2 = TupleList3 = [Tuple] -  Tuple = tuple() - + 1..tuple_size(Tuple) -

Returns the sorted list formed by merging TupleList1 - and TupleList2. The merge is performed on the - Nth element of each tuple. Both TupleList1 and - TupleList2 must be key-sorted without duplicates +

Returns the sorted list formed by merging TupleList1 + and TupleList2. The merge is performed on the + Nth element of each tuple. Both TupleList1 and + TupleList2 must be key-sorted without duplicates prior to evaluating this function. When two tuples compare - equal, the tuple from TupleList1 is picked and the - one from TupleList2 deleted.

+ equal, the tuple from TupleList1 is picked and the + one from TupleList2 deleted.

- ukeysort(N, TupleList1) -> TupleList2 + Sort a list of tuples, removing duplicates - - N = 1..tuple_size(Tuple) - TupleList1 = TupleList2 = [Tuple] -  Tuple = tuple() - + 1..tuple_size(Tuple)

Returns a list containing the sorted elements of the list - TupleList1 where all but the first tuple of the + TupleList1 where all but the first tuple of the tuples comparing equal have been deleted. Sorting is - performed on the Nth element of the tuples.

+ performed on the Nth element of the tuples.

- umerge(ListOfLists) -> List1 + Merge a list of sorted lists, removing duplicates - - ListOfLists = [List] - List = List1 = [term()] -

Returns the sorted list formed by merging all the sub-lists - of ListOfLists. All sub-lists must be sorted and + of ListOfLists. All sub-lists must be sorted and contain no duplicates prior to evaluating this function. When two elements compare equal, the element from the - sub-list with the lowest position in ListOfLists is + sub-list with the lowest position in ListOfLists is picked and the other one deleted.

- umerge(List1, List2) -> List3 + Merge two sorted lists, removing duplicates - - List1 = List2 = List3 = [term()] - -

Returns the sorted list formed by merging List1 and - List2. Both List1 and List2 must be +

Returns the sorted list formed by merging List1 and + List2. Both List1 and List2 must be sorted and contain no duplicates prior to evaluating this function. When two elements compare equal, the element from - List1 is picked and the one from List2 + List1 is picked and the one from List2 deleted.

- umerge(Fun, List1, List2) -> List3 + Merge two sorted lists, removing duplicates - - Fun = fun(A, B) -> bool() - List1 = [A] - List2 = [B] - List3 = [A | B] -  A = B = term() - -

Returns the sorted list formed by merging List1 and - List2. Both List1 and List2 must be +

Returns the sorted list formed by merging List1 and + List2. Both List1 and List2 must be sorted according to the ordering function Fun and contain no duplicates prior to evaluating - this function. Fun(A, B) should return true if - A compares less than or equal to B in the + this function. Fun(A, B) should return true if + A compares less than or equal to B in the ordering, false otherwise. When two elements compare equal, the element from - List1 is picked and the one from List2 + List1 is picked and the one from List2 deleted.

- umerge3(List1, List2, List3) -> List4 + Merge three sorted lists, removing duplicates - - List1 = List2 = List3 = List4 = [term()] - -

Returns the sorted list formed by merging List1, - List2 and List3. All of List1, - List2 and List3 must be sorted and contain no +

Returns the sorted list formed by merging List1, + List2 and List3. All of List1, + List2 and List3 must be sorted and contain no duplicates prior to evaluating this function. When two - elements compare equal, the element from List1 is + elements compare equal, the element from List1 is picked if there is such an element, otherwise the element - from List2 is picked, and the other one deleted.

+ from List2 is picked, and the other one deleted.

- unzip(List1) -> {List2, List3} + Unzip a list of two-tuples into two lists - - List1 = [{X, Y}] - List2 = [X] - List3 = [Y] -  X = Y = term() -

"Unzips" a list of two-tuples into two lists, where the first list contains the first element of each tuple, and the second @@ -1063,15 +818,8 @@ splitwith(Pred, List) -> - unzip3(List1) -> {List2, List3, List4} + Unzip a list of three-tuples into three lists - - List1 = [{X, Y, Z}] - List2 = [X] - List3 = [Y] - List4 = [Z] -  X = Y = Z = term() -

"Unzips" a list of three-tuples into three lists, where the first list contains the first element of each tuple, @@ -1080,44 +828,30 @@ splitwith(Pred, List) -> - usort(List1) -> List2 + Sort a list, removing duplicates - - List1 = List2 = [term()] -

Returns a list containing the sorted elements of - List1 where all but the first element of the elements + List1 where all but the first element of the elements comparing equal have been deleted.

- usort(Fun, List1) -> List2 + Sort a list, removing duplicates - - Fun = fun(Elem1, Elem2) -> bool() -  Elem1 = Elem2 = term() - List1 = List2 = [term()] -

Returns a list which contains the sorted elements of - List1 where all but the first element of the elements + List1 where all but the first element of the elements comparing equal according to the ordering function - Fun have been deleted. Fun(A, B) should return + Fun have been deleted. Fun(A, B) should return true if A compares less than or equal to B in the ordering, false otherwise.

- zip(List1, List2) -> List3 + Zip two lists into a list of two-tuples - - List1 = [X] - List2 = [Y] - List3 = [{X, Y}] -  X = Y = term() -

"Zips" two lists of equal length into one list of two-tuples, where the first element of each tuple is taken from the first @@ -1126,15 +860,8 @@ splitwith(Pred, List) -> - zip3(List1, List2, List3) -> List4 + Zip three lists into a list of three-tuples - - List1 = [X] - List2 = [Y] - List3 = [Z] - List3 = [{X, Y, Z}] -  X = Y = Z = term() -

"Zips" three lists of equal length into one list of three-tuples, where the first element of each tuple is taken @@ -1145,20 +872,13 @@ splitwith(Pred, List) -> - zipwith(Combine, List1, List2) -> List3 + Zip two lists into one list according to a fun - - Combine = fun(X, Y) -> T - List1 = [X] - List2 = [Y] - List3 = [T] -  X = Y = T = term() -

Combine the elements of two lists of equal length into one - list. For each pair X, Y of list elements from the two + list. For each pair X, Y of list elements from the two lists, the element in the result list will be - Combine(X, Y).

+ Combine(X, Y).

zipwith(fun(X, Y) -> {X,Y} end, List1, List2) is equivalent to zip(List1, List2).

Example:

@@ -1168,21 +888,13 @@ splitwith(Pred, List) ->
- zipwith3(Combine, List1, List2, List3) -> List4 + Zip three lists into one list according to a fun - - Combine = fun(X, Y, Z) -> T - List1 = [X] - List2 = [Y] - List3 = [Z] - List4 = [T] -  X = Y = Z = T = term() -

Combine the elements of three lists of equal length into one - list. For each triple X, Y, Z of list elements from + list. For each triple X, Y, Z of list elements from the three lists, the element in the result list will be - Combine(X, Y, Z).

+ Combine(X, Y, Z).

zipwith3(fun(X, Y, Z) -> {X,Y,Z} end, List1, List2, List3) is equivalent to zip3(List1, List2, List3).

Examples:

-- 
cgit v1.2.3