[Haskell-cafe] List manipulation
jules at jellybean.co.uk
Wed Jan 26 11:50:51 EST 2005
On 26 Jan 2005, at 16:39, Dmitri Pissarenko wrote:
Have a browse around the haskell wiki! There's loads of interesting
information and example code there...
> add2Img summand1 summand2 = sum
> where sum = [ (x+y) | x <- summand1, y <- summand2 ]
> instead of
> [1, 2, 100].
[(x+y) | x <- summand1, y <- summand2] means *all* possible sums x+y
with x taken from the first list and y from the second. This is the
nature of list comprehensions.
You rather want 'zipWith'. Documentation at:
...along with lots of other funky list processing stuff.
More information about the Haskell-Cafe