HASKELL   27
getArgs
Guest on 7th March 2023 01:38:43 PM


  1. module Main where
  2.  
  3. import System
  4.  
  5. main :: IO ()
  6. main = do args <- getArgs
  7.           mapM_ (\row -> putStrLn (show row)) $ getMatrix (read $ head args ::Int)
  8.  
  9. getMatrix :: Int -> [[Bool]]
  10. getMatrix n = take n $ map (take n) ss
  11.  
  12. ss :: [[Bool]]
  13. ss = map s [0..]
  14.  
  15. s :: Int -> [Bool]
  16. s 0 = cycle [False]
  17. s 1 = cycle [True]
  18. s n = cycle $ map (!! n) $ take n ss

Raw Paste

Login or Register to edit or fork this paste. It's free.