Narcissistic decimal number: Difference between revisions

m
→‎{{header|Haskell}}: (Some slight simplifications, and some generalisation of map to fmap)
(Added Agena)
m (→‎{{header|Haskell}}: (Some slight simplifications, and some generalisation of map to fmap))
Line 1,069:
 
digits :: (Read a, Show a) => a -> [a]
digits n = map ((read . (:[])return) <$>) show. nshow
 
isNarcissistic :: (Show a, Read a, Num a, Eq a) => a -> Bool
Line 1,075:
let dig = digits n
len = length dig
in n == (sum $ map ((^ len) <$> dig)
 
main :: IO ()
main = do
hSetBuffering stdout NoBuffering
putStrLn $ unwords $ map show <$> take 25 $ (filter isNarcissistic [(0 :: Int) ..])</lang>
 
=={{header|Icon}} and {{header|Unicon}}==
9,655

edits