RosettaCodeData/Task/Identity-matrix/Haskell/identity-matrix-5.hs

8 lines
183 B
Haskell
Raw Permalink Normal View History

2018-08-17 15:15:24 +01:00
idMatrix :: Int -> [[Int]]
idMatrix n =
let xs = [1 .. n]
in (\x -> fromEnum . (x ==) <$> xs) <$> xs
main :: IO ()
main = (putStr . unlines) $ unwords . fmap show <$> idMatrix 5