Paste-bin.xyz
Archive
Sign In
Login
Register
Username
Current Password
Keep me signed in.
Username
Full Name
Email
New Password
HASKELL
27
getArgs
Guest on 7th March 2023 01:38:43 PM
module
Main
where
import
System
main
::
IO
(
)
main
=
do
args
<-
getArgs
mapM_
(
\
row
->
putStrLn
(
show
row
)
)
$
getMatrix
(
read
$
head
args
::
Int
)
getMatrix
::
Int
->
[
[
Bool
]
]
getMatrix n
=
take
n
$
map
(
take
n
)
ss
ss
::
[
[
Bool
]
]
ss
=
map
s
[
0
..
]
s
::
Int
->
[
Bool
]
s
0
=
cycle
[
False
]
s
1
=
cycle
[
True
]
s n
=
cycle
$
map
(
!!
n
)
$
take
n ss
Raw Paste
module Main where import System main :: IO () main = do args <- getArgs mapM_ (\row -> putStrLn (show row)) $ getMatrix (read $ head args ::Int) getMatrix :: Int -> [[Bool]] getMatrix n = take n $ map (take n) ss ss :: [[Bool]] ss = map s [0..] s :: Int -> [Bool] s 0 = cycle [False] s 1 = cycle [True] s n = cycle $ map (!! n) $ take n ss
Login
or
Register
to edit or fork this paste. It's free.