On 26 Jan 2005, at 16:39, Dmitri Pissarenko wrote:

Hello!

Hi Dmitri.

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 ]



[3.0,4.0,501.0,4.0,5.0,502.0,102.0,103.0,600.0]

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:

http://www.haskell.org/ghc/docs/latest/html/libraries/base/GHC.List.html

...along with lots of other funky list processing stuff.

Jules

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to