On Mon, 17 Jan 2011 07:45:04 +0000
Blake Rain <[email protected]> wrote:

> So, after drinking  some coffee and having a  smoke, I started the
> Haskell version:
> 
> [foldl (+) 0 $ zipWith (*) x y | x <- m1, y <- transpose m2]
> 

I don't think this is correct; it's type is 

        (Num a) => [[a]] -> [[a]] -> [a]

rather than the expected

        (Num a) => [[a]] -> [[a]] -> [[a]]

How about:

mult m1 m2 = [[foldl (+) 0 $ zipWith (*) x y |  y<-transpose m2] | x<-m1]

Regarding performance: did you make sure you're forcing the
evaluation of the result matrix? 

Regards,

Pedro

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to