Matrix multiplication: Difference between revisions
→With List and without transpose
m (→{{header|Tailspin}}: syntax update) |
|||
Line 2,248:
[-17,-20,25]
</pre>
===With List and without transpose - Shorter===
mult uss vss = map (foldl (zipWith (+)) ts . zipWith (\vs u -> map (u*) vs) vss) $ uss
where ts = map (const 0).concat $ take 1 vss
test a b = do
Line 2,273 ⟶ 2,261:
putStrLn "c = a * b = mult a b ="
mapM_ print c
main = test [[1, 2],[3, 4]] [[-3, -8, 3],[-2, 1, 4]]</lang>
{{out}}
<pre>
|