View Single Post
Old 16-10-2011, 21:41   #6
marco.r
Senior Member
 
Iscritto dal: Dec 2005
Città: Istanbul
Messaggi: 1817
Argh, sto diventando lento a postare XD.

Codice:
scalar_product xs ys = sum $ [ x*y | x <- xs, y <- ys ]
No dovresti usare le parallel list comprehension, che pero' non sono standard
(e togliere un $ di troppo)
Codice:
scalar_product xs ys = sum [ x*y | x <- xs | y <- ys ]
Oppure zippi come nel mio esempio.
__________________
One of the conclusions that we reached was that the "object" need not be a primitive notion in a programming language; one can build objects and their behaviour from little more than assignable value cells and good old lambda expressions. —Guy Steele
marco.r è offline   Rispondi citando il messaggio o parte di esso