RE: Mapping Functions That Take More Than One Argument
- To: mathgroup at smc.vnet.net
- Subject: [mg69899] RE: [mg69864] Mapping Functions That Take More Than One Argument
- From: "David Annetts" <davidannetts at aapt.net.au>
- Date: Wed, 27 Sep 2006 06:04:01 -0400 (EDT)
Hi Gregory,
> How can I map a functions onto sub-lists when the function
> takes more than one argument. I can't seem to stumble upon
> the right syntax.
>
> Here's a list of three sub-lists.
>
> {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
>
> I want to drop the first element of each sub-list, that is, 1
> from the first, 4 from the second, and 7 from the third.
>
> Drop[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, 1]
>
> gives me
>
> {{4, 5, 6}, {7, 8, 9}},
>
> which is what I expected (I'm learning) but not what I want.
> So, how do I apply Drop to each sub-list?
There is Map ...
a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
Drop[#, 1] & /@ a
Running through some of the examples in 2.2.4 might throw some more light on
other applications.
Regards,
Dave