Re: conditionals on lists
- To: mathgroup at smc.vnet.net
- Subject: [mg79146] Re: [mg79088] conditionals on lists
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 19 Jul 2007 03:41:54 -0400 (EDT)
- Reply-to: hanlonr at cox.net
InputForm[data = {First[#], Length[#]} & /@ Split[Table[RandomChoice[{-1, 1}], {20}]]] {{1, 1}, {-1, 1}, {1, 1}, {-1, 1}, {1, 4}, {-1, 1}, {1, 1}, {-1, 2}, {1, 3}, {-1, 3}, {1, 2}} #[[2]]*If[#[[1]] == 1, W, L] & /@ data {W,L,W,L,4 W,L,W,2 L,3 W,3 L,2 W} Bob Hanlon ---- mausgeo at aol.com wrote: > I am trying to run a simulation of a roulette game and I have created > a list of 1's and -1's to represent wins and losses. Using the Split > command I can get ordered pairs with the first coordinate being either > 1 or -1 and the second coordinate being the number of successive > entries. I am having trouble applying a conditional to this new list > as I would like to perform a different function depending on the first > coordinate of the ordered pair. How do I apply a conditional to a list > of ordered pairs? > >