Damm algorithm: Difference between revisions

Content added Content deleted
m (→‎static table: changed a word in the REXX section header.)
Line 627: Line 627:
112949 is invalid</pre>
112949 is invalid</pre>
=={{header|Haskell}}==
=={{header|Haskell}}==
<lang haskell>import Data.Char (ord)
<lang haskell>import Data.Char (digitToInt)
import Text.Printf (printf)
import Text.Printf (printf)


damm :: String -> Bool
damm :: String -> Bool
damm = (==0) . foldl (\r n -> table !! r !! (ord n - ord '0')) 0
damm = (==0) . foldl (\r -> (table !! r !!) . digitToInt) 0
where
where
table =
table =