Skip to content

Instantly share code, notes, and snippets.

@alexandru
Created November 29, 2019 09:01
Show Gist options
  • Save alexandru/6d7f0268c8f24f894e8289f82e801ad0 to your computer and use it in GitHub Desktop.
Save alexandru/6d7f0268c8f24f894e8289f82e801ad0 to your computer and use it in GitHub Desktop.
Prints an ASCII Sierpinski triangle
#!/usr/bin/env stack
-- stack --resolver lts-14.14 script
import Data.Bits
main :: IO ()
main = mapM_ putStrLn lines
where
n = 32 :: Int
line i =
[ if i .&. j /= 0 then ' ' else '*'
| j <- [0 .. n - 1] ]
lines = [line i | i <- [0 .. n - 1]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment