MathGroup Archive 2004

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

Search the Archive

Re: foreach loop

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51941] Re: [mg51868] foreach loop
  • From: János <janos.lobb at yale.edu>
  • Date: Fri, 5 Nov 2004 02:18:23 -0500 (EST)
  • References: <200411040649.BAA18018@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Map[expr,{fall, winter, spring, summer}]

For example:

In[58]:=
seasons = {"Fall", "Winter",
    "Spring", "summer"}
Out[58]=
{"Fall", "Winter", "Spring",
   "summer"}

In[59]:=
(StringTake[#1,
     {2, 3}] & ) /@ seasons
Out[59]=
{"al", "in", "pr", "um"}

János

On Nov 4, 2004, at 1:49 AM, symbio wrote:

> Is there a foreach loop statement in Mathematica?  I need to loop 
> through a
> list of words, rather than numbers.  I need the equivalent of Do[expr,
> {n,0,10,1}], except I need to step through a list like so:  foreach 
> loop
> [expr, {fall, winter, spring, summer}].  Can anyone help?
>
>
----------------------------------------------
Trying to argue with a politician is like lifting up the head of a 
corpse.
(S. Lem: His Master Voice)


  • Prev by Date: Re: Counting Runs
  • Next by Date: Re: Functions with optional parameters
  • Previous by thread: Re: foreach loop
  • Next by thread: Re: foreach loop