Re: foreach loop
- To: mathgroup at smc.vnet.net
- Subject: [mg51944] Re: [mg51868] foreach loop
- From: "David Park" <djmp at earthlink.net>
- Date: Fri, 5 Nov 2004 02:18:41 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
If you want to loop through irregular values use MapThread. MapThread[ Print[Switch[#, fall, "Fallen leaves", winter, "Snow flakes", spring, "Green buds", summer, "Swim suits"]] &, {{fall, winter, spring, summer}}]; David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: symbio [mailto:symbio at has.com] To: mathgroup at smc.vnet.net 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?