Last active
December 21, 2015 22:01
-
-
Save leksak/e3bc4a9bf9f478e678d8 to your computer and use it in GitHub Desktop.
L-system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE MultiWayIf #-} | |
data Variables = Zero | One | LB | RB deriving (Show, Eq) | |
-- LB and RB symbolises left and right brackets, i.e. [, ] | |
pythagoras = concatMap (\c -> if | |
| c == Zero -> One : [LB, Zero, RB, Zero] | |
| c == One -> One : [One] | |
| c == LB -> [LB] | |
| c == RB -> [RB]) | |
main :: IO () | |
main = do | |
putStrLn "First generation:" | |
print $ iterate pythagoras [Zero] !! 1 | |
putStrLn "Second generation:" | |
print $ iterate pythagoras [Zero] !! 2 | |
putStrLn "Third generation:" | |
print $ iterate pythagoras [Zero] !! 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment