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