Re: List Manipulation
- To: mathgroup@smc.vnet.net
- Subject: [mg10534] Re: [mg10471] List Manipulation
- From: Bob Hanlon <BobHanlon@aol.com>
- Date: Tue, 20 Jan 1998 02:23:20 -0500
- Organization: AOL (http://www.aol.com)
list1 = {{n1}, {n2}, {n3}, {n4}, {n5}}; list2 = {{n1}, {n2}, {n3}, {n4},
{n5}, {n6}};
listOdd[x_List/; OddQ[Length[x]]] :=
Append[First[Transpose[Partition[x, 2]]], Last[x]] listOdd[x_List/;
EvenQ[Length[x]]&&Length[x]>0] :=
First[Transpose[Partition[x, 2]]]
listEven[x_List/;Length[x]>0] :=
Last[Transpose[Partition[x, 2]]]
listOdd[list1]
{{n1},{n3},{n5}}
listOdd[list2]
{{n1},{n3},{n5}}
listEven[list1]
{{n2},{n4}}
listEven[list2]
{{n2},{n4},{n6}}
Bob Hanlon