Re: [pure-lang-users] list comprehensions
Status: Beta
Brought to you by:
agraef
From: Jiri S. <jir...@bl...> - 2008-07-20 20:40:26
|
Eddie Rucker wrote: > Is there a way to create a new value from separate values inside a list comprehension? > > ranked is a list of lists. I want to addelement 2 and 4 and record the result if > it is positive. Yes, it is trival to do without a list comprehension but I want > to do it with one. > > [v; v > 0; v = rw!2 + rw!4; rw = ranked]; > > I know this doesn't work; > > [v; rw = ranked; v > 0] when v = rw!2 + rw!4 end; > E. g. this way: [v; v = map (\rw -> rw!2 + rw!4) ranked; v > 0]; Jiri |