From 68d53c01b0b8e9a007a6a30158c19e34b2d2a34e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 18 May 2016 15:53:35 +0200 Subject: Update STDLIB documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Language cleaned up by the technical writers xsipewe and tmanevik from Combitech. Proofreading and corrections by Björn Gustavsson and Hans Bolinder. --- lib/stdlib/doc/src/lists.xml | 734 ++++++++++++++++++++++++++----------------- 1 file changed, 438 insertions(+), 296 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 03d0063599..60dbae70c2 100644 --- a/lib/stdlib/doc/src/lists.xml +++ b/lib/stdlib/doc/src/lists.xml @@ -25,11 +25,11 @@ lists Robert Virding 1 - 96-09-28 + 1996-09-28 A lists - List Processing Functions + List processing functions.

This module contains functions for list processing.

@@ -44,132 +44,156 @@

Whenever an ordering function F is expected as argument, it is assumed that the - following properties hold of F for all x, y and z:

+ following properties hold of F for all x, y, and z:

+ -

if x F y and y F x then x = y (F - is antisymmetric);

+

If x F y and y F x, then x = y (F + is antisymmetric).

-

if x F y and y F z then x F z - (F is transitive);

+

If x F y and y F z, then x F z + (F is transitive).

x F y or y F x (F is total).

-

An example of a typical ordering function is less than or equal - to, =</2.

+

An example of a typical ordering function is less than or equal + to: =</2.

+ - Return true if all elements in the list satisfyPred + Return true if all elements in a list satisfy + Pred. -

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

+

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

+ - Return true if any of the elements in the list satisfiesPred + Return true if any of the elements in a list + satisfies Pred. -

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 a list of lists + Append a list of lists. -

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

+

Returns a list in which all the sublists of + ListOfLists have been appended.

+

Example:

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

Returns a new list List3 which is made from +

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

+ List2.

+

Example:

 > lists:append("abc", "def").
 "abcdef"

lists:append(A, B) is equivalent to A ++ B.

+ - Concatenate a list of atoms + Concatenate a list of atoms. -

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

+

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

+

Example:

 > lists:concat([doc, '/', file, '.', 3]).
 "doc/file.3"
+ - Delete an element from a list + Delete an element from a list.

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

+ - Drop the last element of a list + Drop the last element of a list. -

Drops the last element of a List. The list should - be non-empty, otherwise the function will crash with a function_clause

+

Drops the last element of a List. The list is to + be non-empty, otherwise the function crashes with a + function_clause.

+ - Drop elements from a list while a predicate is true + Drop elements from a list while a predicate is true. + -

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

+

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

+ - Make N copies of element + Make N copies of element. -

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

+

Returns a list containing N copies of term + Elem.

+

Example:

 > lists:duplicate(5, xx).
 [xx,xx,xx,xx,xx]
+ - Choose elements which satisfy a predicate + Select elements that satisfy a predicate. -

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

+

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

+ - Filter and map elements which satisfy a function - -

Calls Fun(Elem) on successive elements Elem - of List1. Fun/2 must return either a boolean - or a tuple {true, Value}. The function returns the list of elements - for which Fun returns a new value, where a value of true - is synonymous with {true, Elem}.

-

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

+ Filter and map elements that satisfy a function. + +

Calls Fun(Elem) on successive + elements Elem of List1. + Fun/2 must return either a Boolean or a tuple + {true, Value}. The function returns the list of + elements for which Fun returns a new value, where + a value of true is synonymous with + {true, Elem}.

+

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

filtermap(Fun, List1) -> lists:foldr(fun(Elem, Acc) -> @@ -179,26 +203,29 @@ filtermap(Fun, List1) -> {true,Value} -> [Value|Acc] end end, [], List1). -

Example:

+

Example:

 > lists:filtermap(fun(X) -> case X rem 2 of 0 -> {true, X div 2}; _ -> false end end, [1,2,3,4,5]).
 [1,2]
+ - Length of flattened deep list + Length of flattened deep list. -

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

+

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

+ - Map and flatten in one pass + Map and flatten in one pass. -

Takes a function from As to lists of Bs, and a - list of As (List1) and produces a list of +

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 @@ -206,37 +233,42 @@ filtermap(Fun, List1) -> flatmap(Fun, List1) -> append(map(Fun, List1)). -

Example:

+

Example:

 > lists:flatmap(fun(X)->[X,X] end, [a,b,c]).
 [a,a,b,b,c,c]
+ - Flatten a deep list + Flatten a deep list.

Returns a flattened version of DeepList.

+ - Flatten a deep list + Flatten a deep list. -

Returns a flattened version of DeepList with the tail +

Returns a flattened version of DeepList with tail Tail appended.

+ - Fold a function over a list - -

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. - For example:

+ Fold a function over a list. + +

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.

+

Example:

 > lists:foldl(fun(X, Sum) -> X + Sum end, 0, [1,2,3,4,5]).
 15
@@ -244,12 +276,14 @@ flatmap(Fun, List1) ->
 120
+ - Fold a function over a list + Fold a function over a list. -

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

+

Like foldl/3, but the + list is traversed from right to left.

+

Example:

 > P = fun(A, AccIn) -> io:format("~p ", [A]), AccIn end.
 #Fun<erl_eval.12.2225172>
@@ -257,10 +291,11 @@ flatmap(Fun, List1) ->
 1 2 3 void
 > lists:foldr(P, void, [1,2,3]).
 3 2 1 void
-

foldl/3 is tail recursive and would usually be - preferred to foldr/3.

+

foldl/3 is tail recursive and is usually preferred to + foldr/3.

+ Insert an element between elements in a list @@ -278,45 +313,52 @@ flatmap(Fun, List1) -> - Apply a function to each element of a list + Apply a function to each element of a list. -

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.

+ - Delete an element from a list of tuples + Delete an element from a list of tuples. 1..tuple_size(Tuple)

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

+ - Search for an element in a list of tuples + Search for an element in a list of tuples. 1..tuple_size(Tuple)

Searches the list of tuples TupleList for a - tuple whose Nth element compares equal to Key. + tuple whose Nth element compares equal to + Key. Returns Tuple if such a tuple is found, otherwise false.

+ - Map a function over a list of tuples + Map a function over a list of tuples. 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).

-

Examples:

+

Examples:

 > Fun = fun(Atom) -> atom_to_list(Atom) end.
 #Fun<erl_eval.6.10732646>
@@ -324,33 +366,37 @@ flatmap(Fun, List1) ->
 [{name,"jane",22},{name,"lizzie",20},{name,"lydia",15}]
+ - Test for membership of a list of tuples + Test for membership of a list of tuples. 1..tuple_size(Tuple) -

Returns true if there is a tuple in TupleList - whose Nth element compares equal to Key, otherwise - false.

+

Returns true if there is a tuple in + TupleList whose Nth element + compares equal to Key, otherwise false.

+ - Merge two key-sorted lists of tuples + Merge two key-sorted lists of tuples. 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 - function. When two tuples compare equal, the tuple from +

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 before evaluating + this function. When two tuples compare equal, the tuple from TupleList1 is picked before the tuple from TupleList2.

+ - Replace an element in a list of tuples + Replace an element in a list of tuples. 1..tuple_size(Tuple)

Returns a copy of TupleList1 where the first @@ -359,193 +405,226 @@ flatmap(Fun, List1) -> NewTuple, if there is such a tuple T.

+ - Search for an element in a list of tuples + Search for an element in a list of tuples. 1..tuple_size(Tuple)

Searches the list of tuples TupleList for a - tuple whose Nth element compares equal to Key. + tuple whose Nth element compares equal to + Key. Returns {value, Tuple} if such a tuple is found, otherwise false.

-

This function is retained for backward compatibility. - The function lists:keyfind/3 (introduced in R13A) - is in most cases more convenient.

+ +

This function is retained for backward compatibility. Function + keyfind/3 + is usually more convenient.

+
+ - Sort a list of tuples + Sort a list of tuples. 1..tuple_size(Tuple) -

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

+

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

+ - Store an element in a list of tuples + Store an element in a list of tuples. 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, 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.

+ - Extract an element from a list of tuples + Extract an element from a list of tuples. 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 +

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.

+ - Return last element in a list + Return last element in a list.

Returns the last element in List.

+ - Map a function over a list + Map a function over a list. -

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.

+ used to obtain the return values. The evaluation order depends on + the implementation.

+ - Map and fold in one pass + Map and fold in one pass. -

mapfoldl combines the operations of map/2 and - foldl/3 into one pass. An example, summing - the elements in a list and double them at the same time:

+

Combines the operations of + map/2 and + foldl/3 into one pass.

+

Example:

+

Summing the elements in a list and double them at the same time:

 > lists:mapfoldl(fun(X, Sum) -> {2*X, X+Sum} end,
 0, [1,2,3,4,5]).
 {[2,4,6,8,10],15}
+ - Map and fold in one pass + Map and fold in one pass. -

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

+

Combines the operations of + map/2 and + foldr/3 into one pass.

+ - Return maximum element of a list + Return maximum element of a list.

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

+ - Test for membership of a list + Test for membership of a list. -

Returns true if Elem matches some element of - List, otherwise false.

+

Returns true if Elem matches some element + of List, otherwise false.

+ - Merge a list of sorted lists + Merge a list of sorted lists. -

Returns the sorted list formed by merging all the sub-lists - of ListOfLists. All sub-lists must be sorted prior to +

Returns the sorted list formed by merging all the sublists of + ListOfLists. All sublists must be sorted before 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.

+ the element from the sublist with the lowest position in + ListOfLists is picked before the other + element.

+ - Merge two sorted lists + Merge two sorted lists. -

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 +

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

+ - Merge two sorted list + Merge two sorted list. -

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

+ - Merge three sorted lists + Merge three sorted lists.

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, + List2, and List3. All of + List1, List2, and + List3 must be sorted before evaluating this + function. When two elements compare equal, 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.

+ - Return minimum element of a list + Return minimum element of a list.

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

+ - Return the Nth element of a list + Return the Nth element of a list. 1..length(List) -

Returns the Nth element of List. For example:

+

Returns the Nth element of + List.

+

Example:

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

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:

+

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.

+

Example

 > lists:nthtail(3, [a, b, c, d, e]).
 [d,e]
@@ -557,70 +636,91 @@ c
[]
+ - Partition a list into two lists based on a predicate - -

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.

-

Examples:

+ Partition a list into two lists based on a predicate. + +

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.

+

Examples:

 > lists:partition(fun(A) -> A rem 2 == 1 end, [1,2,3,4,5,6,7]).
 {[1,3,5,7],[2,4,6]}
 > lists:partition(fun(A) -> is_atom(A) end, [a,b,1,c,d,2,3,4,e]).
 {[a,b,c,d,e],[1,2,3,4]}
-

See also splitwith/2 for a different way to partition - a list.

+

For a different way to partition a list, see + splitwith/2.

+ - Test for list prefix + Test for list prefix.

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

+ - Reverse a list + Reverse a list.

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

+ - Reverse a list appending a tail + Reverse a list appending a tail.

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

+ in reverse order, with tail Tail appended.

+

Example:

 > lists:reverse([1, 2, 3, 4], [a, b, c]).
 [4,3,2,1,a,b,c]
+ - Generate a sequence of integers + Generate a sequence of integers. -

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 +

Returns a sequence of integers that starts with + From and contains the successive results of + adding Incr to the previous element, until + To is 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.

+

Failures:

+ + +

If To < + From - Incr + and Incr > 0.

+
+ +

If To > + From - Incr and + Incr < 0.

+
+ +

If Incr =:= 0 and + From =/= To.

+
+

The following equalities hold for all sequences:

-length(lists:seq(From, To)) == To-From+1 -length(lists:seq(From, To, Incr)) == (To-From+Incr) div Incr -

Examples:

+length(lists:seq(From, To)) =:= To - From + 1 +length(lists:seq(From, To, Incr)) =:= (To - From + Incr) div Incr +

Examples:

 > lists:seq(1, 10).
 [1,2,3,4,5,6,7,8,9,10]
@@ -634,74 +734,87 @@ length(lists:seq(From, To, Incr)) == (To-From+Incr) div Incr
 [1]
+ - Sort a list + Sort a list.

Returns a list containing the sorted elements of List1.

+ - Sort a list + Sort a list.

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

+ Fun. Fun(A, + B) is to return true if A + compares less than or equal to B in the + ordering, otherwise false.

+ - Split a list into two lists + Split a list into two lists. 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 remaining elements (the Nth tail).

+ - Split a list into two lists based on a predicate + Split a list into two lists based on a predicate.

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

+ Pred. splitwith/2 behaves as if it is + defined as follows:

splitwith(Pred, List) -> {takewhile(Pred, List), dropwhile(Pred, List)}. -

Examples:

+

Examples:

 > lists:splitwith(fun(A) -> A rem 2 == 1 end, [1,2,3,4,5,6,7]).
 {[1],[2,3,4,5,6,7]}
 > lists:splitwith(fun(A) -> is_atom(A) end, [a,b,1,c,d,2,3,4,e]).
 {[a,b],[1,c,d,2,3,4,e]}
-

See also partition/2 for a different way to partition - a list.

+

For a different way to partition a list, see + partition/2.

+ - Return a sub-list of a certain length, starting at the first position + Return a sublist of a certain length, starting at the first + position. -

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.

+

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

+ - Return a sub-list starting at a given position and with a given number of elements + Return a sublist starting at a specified position and with a + specified number of elements. 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 sublist of List1 starting at + Start and with (maximum) Len + elements. It is not an error for + Start+Len to exceed the length of + the list.

+

Examples:

 > lists:sublist([1,2,3,4], 2, 2).
 [2,3]
@@ -711,142 +824,163 @@ splitwith(Pred, List) ->
 []
+ - Subtract the element in one list from another list + Subtract the element in one list from another list. -

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:

+

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

+

Example:

 > lists:subtract("123212", "212").
 "312".

lists:subtract(A, B) is equivalent to A -- B.

-

The complexity of lists:subtract(A, B) is proportional - to length(A)*length(B), meaning that it will be very slow if - both A and B are long lists. - (Using ordered lists and - ordsets:subtract/2 - is a much better choice if both lists are long.)

+ +

The complexity of lists:subtract(A, B) is proportional to + length(A)*length(B), meaning that it is very slow if both + A and B are long lists. (If both lists are long, it + is a much better choice to use ordered lists and + + ordsets:subtract/2.

+
+ - Test for list suffix + Test for list suffix.

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

+ - Return sum of elements in a list + Return the sum of elements in a list.

Returns the sum of the elements in List.

+ - Take elements from a list while a predicate is true + Take elements from a list while a predicate is true. + -

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

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.

+ - Merge two key-sorted lists of tuples, removing duplicates + Merge two key-sorted lists of tuples, removing duplicates. + 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 - prior to evaluating this function. When two tuples compare - equal, the tuple from TupleList1 is picked and the - one from TupleList2 deleted.

+

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 before evaluating this function. + When two tuples compare equal, the tuple from + TupleList1 is picked and the + one from TupleList2 is deleted.

+ - Sort a list of tuples, removing duplicates + Sort a list of tuples, removing duplicates. 1..tuple_size(Tuple) -

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

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

+ - Merge a list of sorted lists, removing duplicates + Merge a list of sorted lists, removing duplicates. -

Returns the sorted list formed by merging all the sub-lists - 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 - picked and the other one deleted.

+

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

+ - Merge two sorted lists, removing duplicates + Merge two sorted lists, removing duplicates. -

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 +

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

+ List1 is picked and the one from + List2 is deleted.

+ - Merge two sorted lists, removing duplicates + Merge two sorted lists, removing duplicates. -

Returns the sorted list formed by merging List1 and - List2. Both List1 and List2 must be - sorted according to the 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 - ordering, false otherwise. When two elements compare - equal, the element from - List1 is picked and the one from List2 - deleted.

+ Fun and contain no duplicates before evaluating this function. + Fun(A, B) is to return + true if A compares less than or equal to + B in the ordering, otherwise false. When + two elements compare equal, the element from List1 + is picked and the one from List2 is deleted.

+ - Merge three sorted lists, removing duplicates + Merge three sorted lists, removing duplicates.

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 + List2, and List3. All of + List1, List2, and + List3 must be sorted and contain no + duplicates before evaluating this function. When two 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.

+ picked if there is such an element, otherwise the element from + List2 is picked, and the other is deleted.

+ - Unzip a list of two-tuples into two lists + Unzip a list of two-tuples into two lists.

"Unzips" a list of two-tuples into two lists, where the first list contains the first element of each tuple, and the second list contains the second element of each tuple.

+ - Unzip a list of three-tuples into three lists + Unzip a list of three-tuples into three lists.

"Unzips" a list of three-tuples into three lists, where the first list contains the first element of each tuple, @@ -854,76 +988,84 @@ splitwith(Pred, List) -> the third list contains the third element of each tuple.

+ - Sort a list, removing duplicates + Sort a list, removing duplicates.

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

+ List1 where all except the first element of the + elements comparing equal have been deleted.

+ - Sort a list, removing duplicates + Sort a list, removing duplicates. -

Returns a list which contains the sorted elements of - List1 where all but the first element of the elements - comparing equal according to the Returns a list containing the sorted elements of + List1 where all except 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) is to return true if A compares less than or equal to - B in the ordering, false otherwise.

+ B in the ordering, otherwise false.

+ - Zip two lists into a list of two-tuples + Zip two lists into a list of two-tuples.

"Zips" two lists of equal length into one list of two-tuples, where the first element of each tuple is taken from the first - list and the second element is taken from corresponding + list and the second element is taken from the corresponding element in the second list.

+ - Zip three lists into a list of three-tuples + Zip three lists into a list of three-tuples.

"Zips" three lists of equal length into one list of three-tuples, where the first element of each tuple is taken from the first list, the second element is taken from - corresponding element in the second list, and the third - element is taken from the corresponding element in the third - list.

+ the corresponding element in the second list, and the third + element is taken from the corresponding element in the third list.

+ - Zip two lists into one list according to a fun + Zip two lists into one list according to a fun. -

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

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

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

-

Example:

+

Example:

 > lists:zipwith(fun(X, Y) -> X+Y end, [1,2,3], [4,5,6]).
 [5,7,9]
+ - Zip three lists into one list according to a fun - -

Combine the elements of three lists of equal length into one - 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).

-

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

-

Examples:

+ Zip three lists into one list according to a fun. + +

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

+

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

+

Examples:

 > lists:zipwith3(fun(X, Y, Z) -> X+Y+Z end, [1,2,3], [4,5,6], [7,8,9]).
 [12,15,18]
-- 
cgit v1.2.3