Self-describing numbers: Difference between revisions

→‎{{header|Haskell}}: hlint, hindent – minor tidying
(→‎{{header|Haskell}}: hlint, hindent – minor tidying)
Line 791:
 
isSelfDescribing :: Integer -> Bool
isSelfDescribing n = nu == f
nu == f where
nu = mapdigitToInt digitToInt<$> (show n)
f = map (\a -> `count a` nu) <$> [0 .. ((length nu) - 1)]
 
main :: IO ()
main = do
print $
let tests = [1210, 2020, 21200, 3211000,
isSelfDescribing <$>
42101000, 521001000, 6210001000]
let tests = [1210, 2020, 21200, 3211000, 42101000, 521001000, 6210001000]
print $ map isSelfDescribing tests
print $ filter isSelfDescribing [0 .. 4000000]</lang>
Output:
<pre>[True,True,True,True,True,True,True]
9,659

edits