
Hi why don't you try something like this: map (\(x,y) -> x+y) (zip [1,2,100] [2,3,500]) list comprehension would sum every element of the firs list with every element of the second. On Wed, 2005-01-26 at 17:39 +0100, Dmitri Pissarenko wrote:
Hello!
I have two lists of Double with equal length and want to create a third one, in which each element is the sum of the corresponding element of the first list and the second list.
If list1 is [1, 2, 100] and list2 is [2, 3, 500], then the result of the operation I desire is [3, 5, 600].
I wrote this function
<function> add2Img :: [Double] -> [Double] -> [Double] add2Img summand1 summand2 = sum where sum = [ (x+y) | x <- summand1, y <- summand2 ] </function>,
but I'm getting
[3.0,4.0,501.0,4.0,5.0,502.0,102.0,103.0,600.0]
instead of
[1, 2, 100].
What is wrong with the function above?
TIA
Dmitri Pissarenko -- Dmitri Pissarenko Software Engineer http://dapissarenko.com _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe --
Luca Marchetti Senior Application Specialist Bizmatica S.p.A. Via Pietrasanta, 14 - Building 3a 20141 Milano, Italy e-mail: luca.marchetti@bizmatica.com