Matrix multiplication: Difference between revisions
→With List and without transpose - shorter: Applied hlint and hindent.
(→With List and without transpose - shorter: Applied hlint and hindent.) |
|||
Line 2,249:
</pre>
===With List and without transpose - shorter===
<lang Haskell>mult :: Num a => [[a]] -> [[a]] -> [[a]]
mult uss vss =
map
((\xs ->
main = mapM_ print $ mult [[1, 2],[3, 4]] [[-3, -8, 3],[-2, 1, 4]]</lang>▼
if null xs
then []
else foldl1 (zipWith (+)) xs) .
zipWith (flip (map . (*))) vss)
uss
main :: IO ()
{{out}}
<pre>[-7,-6,11]
|