Kronecker product: Difference between revisions

Content added Content deleted
(→‎JS ES6: Changed top level of kprod to concatMap - a little cleaner)
(→‎{{header|Haskell}}: (slight reformulation for fewer maps))
Line 36:
:: Num a
=> [[a]] -> [[a]] -> [[a]]
kprod xs ys = concat $ (fmap concat . transpose) <$> ks
let f = fmap . fmap . (*) -- Multiplication by n over list of lists
where
in (concat ks<$>) . transpose =<< fmap (`f` ys) <$> xs
f = fmap . fmap . (*)
 
main :: IO ()
Line 65 ⟶ 64:
[0,0,0,0,1,0,0,1,0,0,0,0]
[0,0,0,0,1,1,1,1,0,0,0,0]</pre>
 
=={{header|JavaScript}}==
===Imperative===