Re: Simple list operation
- To: mathgroup at smc.vnet.net
- Subject: [mg59448] Re: [mg59420] Simple list operation
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Wed, 10 Aug 2005 02:55:52 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
test = {{{4, 5}, {5, 9}, {6, 2}},
{{2, 3}, {3, 5}},
{{7, 1}, {9, 8}, {0, 7}, {2, 8}},
{{4, 3}, {6, 5}}};
Drop[#,-1]&/@test
{{{4, 5}, {5, 9}}, {{2, 3}}, {{7, 1}, {9, 8}, {0, 7}},
{{4, 3}}}
New in version 5:
Most/@test
{{{4, 5}, {5, 9}}, {{2, 3}}, {{7, 1}, {9, 8}, {0, 7}},
{{4, 3}}}
%==%%
True
Bob Hanlon
>
> From: Steve Gray <stevebg at adelphia.net>
To: mathgroup at smc.vnet.net
> Date: 2005/08/09 Tue AM 03:30:49 EDT
> Subject: [mg59448] [mg59420] Simple list operation
>
>
> Not having used Mathematica for months, I have forgotten some of the
little I knew.
>
> I have a list of lists like this:
>
> test = { {{4, 5}, {5, 9}, {6, 2}},
> {{2, 3}, {3, 5}},
> {{7,1}, {9, 8}, {0, 7}, {2, 8}},
> {{4, 3}, {6, 5}}};
> test // ColumnForm
> {{{4, 5}, {5, 9}, {6, 2}},
> {{2, 3}, {3, 5}},
> {{7, 1}, {9, 8}, {0, 7}, {2, 8}},
> {{4, 3}, {6, 5}}}
>
> What I want to do is just remove the last element in each sublist, with this
result:
>
> {{{4, 5}, {5, 9}},
> {{2, 3}},
> {{7, 1}, {9, 8}, {0, 7}},
> {{4, 3}}}
>
> There must be some simple functional way to do this, but I haven't found
it.
> I will appreciate any tips. Thank you.
>
> Steve Gray
>
>