Re: list manipulation problem

*To*: mathgroup at smc.vnet.net*Subject*: [mg9083] Re: [mg9062] list manipulation problem*From*: Allan Hayes <hay at haystack.demon.co.uk>*Date*: Mon, 13 Oct 1997 23:33:01 -0400*Sender*: owner-wri-mathgroup at wolfram.com

Teemu Vesanen <Teemu.Vesanen at sci.fi> [mg9062] list manipulation problem > I have a list like > {{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}} Teemu: lst = {{a, b, c}, {d, e, f}, {g, h, i}}; Drop[#,-1]&/@lst {{a, b}, {d, e}, {g, h}} or Transpose[Drop[Transpose[lst],-1]] {{a, b}, {d, e}, {g, h}} (using Thread instead of Transpose is often quicker) Of course the techniques can be used more generally Drop[#,{2}]&/@lst {{a, c}, {d, f}, {g, i}} Allan Hayes hay at haystack.demon.co.uk http://www.haystack.demon.co.uk/training.html voice:+44 (0)116 2714198 fax: +44 (0)116 2718642 Leicester, UK