Provided by: erlang-manpages_22.0.7+dfsg-1_all

**NAME**

lists - List processing functions.

**DESCRIPTION**

This module contains functions for list processing. Unless otherwise stated, all functions assume that position numbering starts at 1. That is, the first element of a list is at position 1. Two termsT1andT2compare equal ifT1==T2evaluates totrue. They match ifT1=:=T2evaluates totrue. Whenever anorderingfunctionFis expected as argument, it is assumed that the following properties hold ofFfor all x, y, and z: * If xFy and yFx, then x = y (Fis antisymmetric). * If xFy and yFz, then xFz (Fis transitive). * xFy or yFx (Fis total). An example of a typical ordering function is less than or equal to:=</2.

**EXPORTS**

all(Pred,List)->boolean()Types: Pred = fun((Elem :: T) -> boolean()) List = [T] T = term() ReturnstrueifPred(Elem)returnstruefor all elementsEleminList, otherwisefalse.any(Pred,List)->boolean()Types: Pred = fun((Elem :: T) -> boolean()) List = [T] T = term() ReturnstrueifPred(Elem)returnstruefor at least one elementEleminList.append(ListOfLists)->List1Types: ListOfLists = [List] List = List1 = [T] T = term() Returns a list in which all the sublists ofListOfListshave been appended.Example:> lists:append([[1, 2, 3], [a, b], [4, 5, 6]]). [1,2,3,a,b,4,5,6]append(List1,List2)->List3Types: List1 = List2 = List3 = [T] T = term() Returns a new listList3, which is made from the elements ofList1followed by the elements ofList2.Example:> lists:append("abc", "def"). "abcdef"lists:append(A,B)is equivalent toA++B.concat(Things)->string()Types: Things = [Thing] Thing = atom() | integer() | float() | string() Concatenates the text representation of the elements ofThings. The elements ofThingscan be atoms, integers, floats, or strings.Example:> lists:concat([doc, '/', file, '.', 3]). "doc/file.3"delete(Elem,List1)->List2Types: Elem = T List1 = List2 = [T] T = term() Returns a copy ofList1where the first element matchingElemis deleted, if there is such an element.droplast(List)->InitListTypes: List = [T, ...] InitList = [T] T = term() Drops the last element of aList. The list is to be non-empty, otherwise the function crashes with afunction_clause.dropwhile(Pred,List1)->List2Types: Pred = fun((Elem :: T) -> boolean()) List1 = List2 = [T] T = term() Drops elementsElemfromList1whilePred(Elem)returnstrueand returns the remaining list.duplicate(N,Elem)->ListTypes: N = integer() >= 0 Elem = T List = [T] T = term() Returns a list containingNcopies of termElem.Example:> lists:duplicate(5, xx). [xx,xx,xx,xx,xx]filter(Pred,List1)->List2Types: Pred = fun((Elem :: T) -> boolean()) List1 = List2 = [T] T = term()List2is a list of all elementsEleminList1for whichPred(Elem)returnstrue.filtermap(Fun,List1)->List2Types: Fun = fun((Elem) -> boolean() | {true, Value}) List1 = [Elem] List2 = [Elem | Value] Elem = Value = term() CallsFun(Elem)on successive elementsElemofList1.Fun/1must return either a Boolean or a tuple{true,Value}. The function returns the list of elements for whichFunreturns a new value, where a value oftrueis synonymous with{true,Elem}. That is,filtermapbehaves as if it had been defined as follows: filtermap(Fun, List1) -> lists:foldr(fun(Elem, Acc) -> case Fun(Elem) of false -> Acc; true -> [Elem|Acc]; {true,Value} -> [Value|Acc] end end, [], List1).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]flatlength(DeepList)->integer()>=0Types: DeepList = [term() | DeepList] Equivalent tolength(flatten(DeepList)), but more efficient.flatmap(Fun,List1)->List2Types: Fun = fun((A) -> [B]) List1 = [A] List2 = [B] A = B = term() Takes a function fromAs to lists ofBs, and a list ofAs (List1) and produces a list ofBs by applying the function to every element inList1and appending the resulting lists. That is,flatmapbehaves as if it had been defined as follows: flatmap(Fun, List1) -> append(map(Fun, List1)).Example:> lists:flatmap(fun(X)->[X,X] end, [a,b,c]). [a,a,b,b,c,c]flatten(DeepList)->ListTypes: DeepList = [term() | DeepList] List = [term()] Returns a flattened version ofDeepList.flatten(DeepList,Tail)->ListTypes: DeepList = [term() | DeepList] Tail = List = [term()] Returns a flattened version ofDeepListwith tailTailappended.foldl(Fun,Acc0,List)->Acc1Types: Fun = fun((Elem :: T, AccIn) -> AccOut) Acc0 = Acc1 = AccIn = AccOut = term() List = [T] T = term() CallsFun(Elem,AccIn)on successive elementsAofList, starting withAccIn==Acc0.Fun/2must return a new accumulator, which is passed to the next call. The function returns the final value of the accumulator.Acc0is returned if the list is empty.Example:> lists:foldl(fun(X, Sum) -> X + Sum end, 0, [1,2,3,4,5]). 15 > lists:foldl(fun(X, Prod) -> X * Prod end, 1, [1,2,3,4,5]). 120foldr(Fun,Acc0,List)->Acc1Types: Fun = fun((Elem :: T, AccIn) -> AccOut) Acc0 = Acc1 = AccIn = AccOut = term() List = [T] T = term() Likefoldl/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> > lists:foldl(P, void, [1,2,3]). 1 2 3 void > lists:foldr(P, void, [1,2,3]). 3 2 1 voidfoldl/3is tail recursive and is usually preferred tofoldr/3.join(Sep,List1)->List2Types: Sep = T List1 = List2 = [T] T = term() InsertsSepbetween each element inList1. Has no effect on the empty list and on a singleton list. For example: > lists:join(x, [a,b,c]). [a,x,b,x,c] > lists:join(x, [a]). [a] > lists:join(x, []). []foreach(Fun,List)->okTypes: Fun = fun((Elem :: T) -> term()) List = [T] T = term() CallsFun(Elem)for each elementEleminList. 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)->TupleList2Types: Key = term() N = integer() >= 1 1..tuple_size(Tuple) TupleList1 = TupleList2 = [Tuple] Tuple = tuple() Returns a copy ofTupleList1where the first occurrence of a tuple whoseNth element compares equal toKeyis deleted, if there is such a tuple.keyfind(Key,N,TupleList)->Tuple|falseTypes: Key = term() N = integer() >= 1 1..tuple_size(Tuple) TupleList = [Tuple] Tuple = tuple() Searches the list of tuplesTupleListfor a tuple whoseNth element compares equal toKey. ReturnsTupleif such a tuple is found, otherwisefalse.keymap(Fun,N,TupleList1)->TupleList2Types: Fun = fun((Term1 :: term()) -> Term2 :: term()) N = integer() >= 1 1..tuple_size(Tuple) TupleList1 = TupleList2 = [Tuple] Tuple = tuple() Returns a list of tuples where, for each tuple inTupleList1, theNth elementTerm1of the tuple has been replaced with the result of callingFun(Term1).Examples:> Fun = fun(Atom) -> atom_to_list(Atom) end. #Fun<erl_eval.6.10732646> 2> lists:keymap(Fun, 2, [{name,jane,22},{name,lizzie,20},{name,lydia,15}]). [{name,"jane",22},{name,"lizzie",20},{name,"lydia",15}]keymember(Key,N,TupleList)->boolean()Types: Key = term() N = integer() >= 1 1..tuple_size(Tuple) TupleList = [Tuple] Tuple = tuple() Returnstrueif there is a tuple inTupleListwhoseNth element compares equal toKey, otherwisefalse.keymerge(N,TupleList1,TupleList2)->TupleList3Types: N = integer() >= 1 1..tuple_size(Tuple) TupleList1 = [T1] TupleList2 = [T2] TupleList3 = [T1 | T2] T1 = T2 = Tuple Tuple = tuple() Returns the sorted list formed by mergingTupleList1andTupleList2. The merge is performed on theNth element of each tuple. BothTupleList1andTupleList2must be key-sorted before evaluating this function. When two tuples compare equal, the tuple fromTupleList1is picked before the tuple fromTupleList2.keyreplace(Key,N,TupleList1,NewTuple)->TupleList2Types: Key = term() N = integer() >= 1 1..tuple_size(Tuple) TupleList1 = TupleList2 = [Tuple] NewTuple = Tuple Tuple = tuple() Returns a copy ofTupleList1where the first occurrence of aTtuple whoseNth element compares equal toKeyis replaced withNewTuple, if there is such a tupleT.keysearch(Key,N,TupleList)->{value,Tuple}|falseTypes: Key = term() N = integer() >= 1 1..tuple_size(Tuple) TupleList = [Tuple] Tuple = tuple() Searches the list of tuplesTupleListfor a tuple whoseNth element compares equal toKey. Returns{value,Tuple}if such a tuple is found, otherwisefalse.Note:This function is retained for backward compatibility. Functionkeyfind/3is usually more convenient.keysort(N,TupleList1)->TupleList2Types: N = integer() >= 1 1..tuple_size(Tuple) TupleList1 = TupleList2 = [Tuple] Tuple = tuple() Returns a list containing the sorted elements of listTupleList1. Sorting is performed on theNth element of the tuples. The sort is stable.keystore(Key,N,TupleList1,NewTuple)->TupleList2Types: Key = term() N = integer() >= 1 1..tuple_size(Tuple) TupleList1 = [Tuple] TupleList2 = [Tuple, ...] NewTuple = Tuple Tuple = tuple() Returns a copy ofTupleList1where the first occurrence of a tupleTwhoseNth element compares equal toKeyis replaced withNewTuple, if there is such a tupleT. If there is no such tupleT, a copy ofTupleList1where [NewTuple] has been appended to the end is returned.keytake(Key,N,TupleList1)->{value,Tuple,TupleList2}|falseTypes: Key = term() N = integer() >= 1 1..tuple_size(Tuple) TupleList1 = TupleList2 = [tuple()] Tuple = tuple() Searches the list of tuplesTupleList1for a tuple whoseNth element compares equal toKey. Returns{value,Tuple,TupleList2}if such a tuple is found, otherwisefalse.TupleList2is a copy ofTupleList1where the first occurrence ofTuplehas been removed.last(List)->LastTypes: List = [T, ...] Last = T T = term() Returns the last element inList.map(Fun,List1)->List2Types: Fun = fun((A) -> B) List1 = [A] List2 = [B] A = B = term() Takes a function fromAs toBs, and a list ofAs and produces a list ofBs by applying the function to every element in the list. This function is used to obtain the return values. The evaluation order depends on the implementation.mapfoldl(Fun,Acc0,List1)->{List2,Acc1}Types: Fun = fun((A, AccIn) -> {B, AccOut}) Acc0 = Acc1 = AccIn = AccOut = term() List1 = [A] List2 = [B] A = B = term() Combines the operations ofmap/2andfoldl/3into 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}mapfoldr(Fun,Acc0,List1)->{List2,Acc1}Types: Fun = fun((A, AccIn) -> {B, AccOut}) Acc0 = Acc1 = AccIn = AccOut = term() List1 = [A] List2 = [B] A = B = term() Combines the operations ofmap/2andfoldr/3into one pass.max(List)->MaxTypes: List = [T, ...] Max = T T = term() Returns the first element ofListthat compares greater than or equal to all other elements ofList.member(Elem,List)->boolean()Types: Elem = T List = [T] T = term() ReturnstrueifElemmatches some element ofList, otherwisefalse.merge(ListOfLists)->List1Types: ListOfLists = [List] List = List1 = [T] T = term() Returns the sorted list formed by merging all the sublists ofListOfLists. All sublists must be sorted before evaluating this function. When two elements compare equal, the element from the sublist with the lowest position inListOfListsis picked before the other element.merge(List1,List2)->List3Types: List1 = [X] List2 = [Y] List3 = [X | Y] X = Y = term() Returns the sorted list formed by mergingList1andList2. BothList1andList2must be sorted before evaluating this function. When two elements compare equal, the element fromList1is picked before the element fromList2.merge(Fun,List1,List2)->List3Types: Fun = fun((A, B) -> boolean()) List1 = [A] List2 = [B] List3 = [A | B] A = B = term() Returns the sorted list formed by mergingList1andList2. BothList1andList2must be sorted according to theorderingfunctionFunbefore evaluating this function.Fun(A,B)is to returntrueifAcompares less than or equal toBin the ordering, otherwisefalse. When two elements compare equal, the element fromList1is picked before the element fromList2.merge3(List1,List2,List3)->List4Types: List1 = [X] List2 = [Y] List3 = [Z] List4 = [X | Y | Z] X = Y = Z = term() Returns the sorted list formed by mergingList1,List2, andList3. All ofList1,List2, andList3must be sorted before evaluating this function. When two elements compare equal, the element fromList1, if there is such an element, is picked before the other element, otherwise the element fromList2is picked before the element fromList3.min(List)->MinTypes: List = [T, ...] Min = T T = term() Returns the first element ofListthat compares less than or equal to all other elements ofList.nth(N,List)->ElemTypes: N = integer() >= 1 1..length(List) List = [T, ...] Elem = T T = term() Returns theNth element ofList.Example:> lists:nth(3, [a, b, c, d, e]). cnthtail(N,List)->TailTypes: N = integer() >= 0 0..length(List) List = [T, ...] Tail = [T] T = term() Returns theNth tail ofList, that is, the sublist ofListstarting atN+1and continuing up to the end of the list.Example> lists:nthtail(3, [a, b, c, d, e]). [d,e] > tl(tl(tl([a, b, c, d, e]))). [d,e] > lists:nthtail(0, [a, b, c, d, e]). [a,b,c,d,e] > lists:nthtail(5, [a, b, c, d, e]). []partition(Pred,List)->{Satisfying,NotSatisfying}Types: Pred = fun((Elem :: T) -> boolean()) List = Satisfying = NotSatisfying = [T] T = term() PartitionsListinto two lists, where the first list contains all elements for whichPred(Elem)returnstrue, and the second list contains all elements for whichPred(Elem)returnsfalse.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]} For a different way to partition a list, seesplitwith/2.prefix(List1,List2)->boolean()Types: List1 = List2 = [T] T = term() ReturnstrueifList1is a prefix ofList2, otherwisefalse.reverse(List1)->List2Types: List1 = List2 = [T] T = term() Returns a list with the elements inList1in reverse order.reverse(List1,Tail)->List2Types: List1 = [T] Tail = term() List2 = [T] T = term() Returns a list with the elements inList1in reverse order, with tailTailappended.Example:> lists:reverse([1, 2, 3, 4], [a, b, c]). [4,3,2,1,a,b,c]search(Pred,List)->{value,Value}|falseTypes: Pred = fun((T) -> boolean()) List = [T] Value = T If there is aValueinListsuch thatPred(Value)returnstrue, returns{value,Value}for the first suchValue, otherwise returnsfalse.seq(From,To)->Seqseq(From,To,Incr)->SeqTypes: From = To = Incr = integer() Seq = [integer()] Returns a sequence of integers that starts withFromand contains the successive results of addingIncrto the previous element, untilTois reached or passed (in the latter case,Tois not an element of the sequence).Incrdefaults to 1. Failures: * IfTo<From-IncrandIncr>0. * IfTo>From-IncrandIncr<0. * IfIncr=:=0andFrom=/=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 IncrExamples:> lists:seq(1, 10). [1,2,3,4,5,6,7,8,9,10] > lists:seq(1, 20, 3). [1,4,7,10,13,16,19] > lists:seq(1, 0, 1). [] > lists:seq(10, 6, 4). [] > lists:seq(1, 1, 0). [1]sort(List1)->List2Types: List1 = List2 = [T] T = term() Returns a list containing the sorted elements ofList1.sort(Fun,List1)->List2Types: Fun = fun((A :: T, B :: T) -> boolean()) List1 = List2 = [T] T = term() Returns a list containing the sorted elements ofList1, according to theorderingfunctionFun.Fun(A,B)is to returntrueifAcompares less than or equal toBin the ordering, otherwisefalse.split(N,List1)->{List2,List3}Types: N = integer() >= 0 0..length(List1) List1 = List2 = List3 = [T] T = term() SplitsList1intoList2andList3.List2contains the firstNelements andList3the remaining elements (theNth tail).splitwith(Pred,List)->{List1,List2}Types: Pred = fun((T) -> boolean()) List = List1 = List2 = [T] T = term() PartitionsListinto two lists according toPred.splitwith/2behaves as if it is defined as follows: splitwith(Pred, List) -> {takewhile(Pred, List), dropwhile(Pred, List)}.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]} For a different way to partition a list, seepartition/2.sublist(List1,Len)->List2Types: List1 = List2 = [T] Len = integer() >= 0 T = term() Returns the sublist ofList1starting at position 1 and with (maximum)Lenelements. It is not an error forLento exceed the length of the list, in that case the whole list is returned.sublist(List1,Start,Len)->List2Types: List1 = List2 = [T] Start = integer() >= 1 1..(length(List1)+1) Len = integer() >= 0 T = term() Returns the sublist ofList1starting atStartand with (maximum)Lenelements. It is not an error forStart+Lento exceed the length of the list.Examples:> lists:sublist([1,2,3,4], 2, 2). [2,3] > lists:sublist([1,2,3,4], 2, 5). [2,3,4] > lists:sublist([1,2,3,4], 5, 2). []subtract(List1,List2)->List3Types: List1 = List2 = List3 = [T] T = term() Returns a new listList3that is a copy ofList1, subjected to the following procedure: for each element inList2, its first occurrence inList1is deleted.Example:> lists:subtract("123212", "212"). "312".lists:subtract(A,B)is equivalent toA--B.suffix(List1,List2)->boolean()Types: List1 = List2 = [T] T = term() ReturnstrueifList1is a suffix ofList2, otherwisefalse.sum(List)->number()Types: List = [number()] Returns the sum of the elements inList.takewhile(Pred,List1)->List2Types: Pred = fun((Elem :: T) -> boolean()) List1 = List2 = [T] T = term() Takes elementsElemfromList1whilePred(Elem)returnstrue, that is, the function returns the longest prefix of the list for which all elements satisfy the predicate.ukeymerge(N,TupleList1,TupleList2)->TupleList3Types: N = integer() >= 1 1..tuple_size(Tuple) TupleList1 = [T1] TupleList2 = [T2] TupleList3 = [T1 | T2] T1 = T2 = Tuple Tuple = tuple() Returns the sorted list formed by mergingTupleList1andTupleList2. The merge is performed on theNth element of each tuple. BothTupleList1andTupleList2must be key-sorted without duplicates before evaluating this function. When two tuples compare equal, the tuple fromTupleList1is picked and the one fromTupleList2is deleted.ukeysort(N,TupleList1)->TupleList2Types: N = integer() >= 1 1..tuple_size(Tuple) TupleList1 = TupleList2 = [Tuple] Tuple = tuple() Returns a list containing the sorted elements of listTupleList1where all except the first tuple of the tuples comparing equal have been deleted. Sorting is performed on theNth element of the tuples.umerge(ListOfLists)->List1Types: ListOfLists = [List] List = List1 = [T] T = term() Returns the sorted list formed by merging all the sublists ofListOfLists. 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 inListOfListsis picked and the other is deleted.umerge(List1,List2)->List3Types: List1 = [X] List2 = [Y] List3 = [X | Y] X = Y = term() Returns the sorted list formed by mergingList1andList2. BothList1andList2must be sorted and contain no duplicates before evaluating this function. When two elements compare equal, the element fromList1is picked and the one fromList2is deleted.umerge(Fun,List1,List2)->List3Types: Fun = fun((A, B) -> boolean()) List1 = [A] List2 = [B] List3 = [A | B] A = B = term() Returns the sorted list formed by mergingList1andList2. BothList1andList2must be sorted according to theorderingfunctionFunand contain no duplicates before evaluating this function.Fun(A,B)is to returntrueifAcompares less than or equal toBin the ordering, otherwisefalse. When two elements compare equal, the element fromList1is picked and the one fromList2is deleted.umerge3(List1,List2,List3)->List4Types: List1 = [X] List2 = [Y] List3 = [Z] List4 = [X | Y | Z] X = Y = Z = term() Returns the sorted list formed by mergingList1,List2, andList3. All ofList1,List2, andList3must be sorted and contain no duplicates before evaluating this function. When two elements compare equal, the element fromList1is picked if there is such an element, otherwise the element fromList2is picked, and the other is deleted.unzip(List1)->{List2,List3}Types: List1 = [{A, B}] List2 = [A] List3 = [B] A = B = term() "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.unzip3(List1)->{List2,List3,List4}Types: List1 = [{A, B, C}] List2 = [A] List3 = [B] List4 = [C] A = B = C = term() "Unzips" a list of three-tuples into three lists, where the first list contains the first element of each tuple, the second list contains the second element of each tuple, and the third list contains the third element of each tuple.usort(List1)->List2Types: List1 = List2 = [T] T = term() Returns a list containing the sorted elements ofList1where all except the first element of the elements comparing equal have been deleted.usort(Fun,List1)->List2Types: Fun = fun((T, T) -> boolean()) List1 = List2 = [T] T = term() Returns a list containing the sorted elements ofList1where all except the first element of the elements comparing equal according to theorderingfunctionFunhave been deleted.Fun(A,B)is to returntrueifAcompares less than or equal toBin the ordering, otherwisefalse.zip(List1,List2)->List3Types: List1 = [A] List2 = [B] List3 = [{A, B}] A = B = 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 list and the second element is taken from the corresponding element in the second list.zip3(List1,List2,List3)->List4Types: List1 = [A] List2 = [B] List3 = [C] List4 = [{A, B, C}] A = B = C = term() "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 the corresponding element in the second list, and the third element is taken from the corresponding element in the third list.zipwith(Combine,List1,List2)->List3Types: Combine = fun((X, Y) -> T) List1 = [X] List2 = [Y] List3 = [T] X = Y = T = term() Combines the elements of two lists of equal length into one list. For each pairX,Yof list elements from the two lists, the element in the result list isCombine(X,Y).zipwith(fun(X,Y)->{X,Y}end,List1,List2)is equivalent tozip(List1,List2).Example:> lists:zipwith(fun(X, Y) -> X+Y end, [1,2,3], [4,5,6]). [5,7,9]zipwith3(Combine,List1,List2,List3)->List4Types: Combine = fun((X, Y, Z) -> T) List1 = [X] List2 = [Y] List3 = [Z] List4 = [T] X = Y = Z = T = term() Combines the elements of three lists of equal length into one list. For each tripleX,Y,Zof list elements from the three lists, the element in the result list isCombine(X,Y,Z).zipwith3(fun(X,Y,Z)->{X,Y,Z}end,List1,List2,List3)is equivalent tozip3(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] > lists:zipwith3(fun(X, Y, Z) -> [X,Y,Z] end, [a,b,c], [x,y,z], [1,2,3]). [[a,x,1],[b,y,2],[c,z,3]]