Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Mapping Functions That Take More Than One Argument

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69916] Re: [mg69864] Mapping Functions That Take More Than One Argument
  • From: János <janos.lobb at yale.edu>
  • Date: Wed, 27 Sep 2006 06:05:15 -0400 (EDT)
  • References: <200609260459.AAA01823@smc.vnet.net>

On Sep 26, 2006, at 12:59 AM, Gregory Lypny wrote:

> Hello everyone,
>
> 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?
>
> Regards,
>
> 	Gregory

Here is two newbie approaches:

In[2]:=
Rest /@ lst
Out[2]=
{{2, 3}, {5, 6}, {8, 9}}

In[3]:=
(Take[#1, {2, Length[
       #1]}] & ) /@ lst
Out[3]=
{{2, 3}, {5, 6}, {8, 9}}

János


  • Prev by Date: RE: How to remove just the outermost braces of a list?
  • Next by Date: Performance comparison Mac OSX vs. Windows XP
  • Previous by thread: Re: Mapping Functions That Take More Than One Argument
  • Next by thread: Re: Mapping Functions That Take More Than One Argument