all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,7 @@
|
|||
sierpinski 0 = ["*"]
|
||||
sierpinski n = map ((space ++) . (++ space)) down ++
|
||||
map (unwords . replicate 2) down
|
||||
where down = sierpinski (n - 1)
|
||||
space = replicate (2 ^ (n - 1)) ' '
|
||||
|
||||
main = mapM_ putStrLn $ sierpinski 4
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import Data.Bits ((.&.))
|
||||
|
||||
sierpinski n = map row [m, m-1 .. 0] where
|
||||
m = 2^n - 1
|
||||
row y = replicate y ' ' ++ concatMap cell [0..m - y] where
|
||||
cell x | y .&. x == 0 = " *"
|
||||
| otherwise = " "
|
||||
|
||||
main = mapM_ putStrLn $ sierpinski 4
|
||||
Loading…
Add table
Add a link
Reference in a new issue