Re: list manipulation problem
- To: mathgroup at smc.vnet.net
- Subject: [mg9090] Re: [mg9062] list manipulation problem
- From: penny at suu.edu (Des Penny)
- Date: Mon, 13 Oct 1997 23:33:06 -0400
- Sender: owner-wri-mathgroup at wolfram.com
>I have a list like=20
>{{a, b, c}, {d, e, f}, {g, h, i}}
>I need to delete the third term of each sublist.
>In other words how do I make the list look like
>{{a, b}, {d, e}, {g, h}}
Hi Teemu:
The following will work:
In:
list={{a, b, c}, {d, e, f}, {g, h, i}};
f[{x_,y_,z_}]:={x,y}
Map[f,list]
Out:
{{a,b},{d,e},{g,h}}
You can also use a pure function:
In:
Map[{#[[1]],#[[2]]}&,list]
Out:
{{a,b},{d,e},{g,h}}
Cheers,
-------------------------------
Des Penny
Physical Science Dept.
Southern Utah University
Cedar City, UT 84720
VOICE: (Office): (801) 586-7708
(Home) : (801) 586-2286
FAX: (801) 865-8051
e-mail: penny at suu.edu
-------------------------------