Long multiplication: Difference between revisions

Imports in the Haskell entry
(→‎{{header|REXX}}: removed REXX version 1. -- ~~~~)
(Imports in the Haskell entry)
Line 1,462:
 
=={{header|Haskell}}==
<lang haskell>digitsimport ::Data.List Integer -> [Integer](transpose)
digitsimport = mapData.Char (fromIntegral.digitToInt) . show
import Data.List (inits)
 
digits :: Integer -> [Integer]
digits = map (fromIntegral . digitToInt) . show
 
lZZ = inits $ repeat 0
Line 1,471 ⟶ 1,475:
polymul = ((map sum . transpose . zipWith (++) lZZ) .) . table (*)
 
longmult = (foldl1 ((+) . (10 *)) .) . (. digits) . polymul . digits</lang>
 
Output:
<langmain haskell>*Main>= print $ (2 ^ 64) `longmult` (2 ^ 64)</lang>
{{out}}
<pre>340282366920938463463374607431768211456</langpre>
 
== {{header|Icon}} and {{header|Unicon}} ==