Created
March 9, 2017 16:41
-
-
Save mwotton/62185dd7b2a74671d703fd4a3b994664 to your computer and use it in GitHub Desktop.
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
data Nested = Empty | Nest Nested | |
deriving Show | |
grow :: Int -> Nested | |
grow 0 = Empty | |
grow n = Nest (grow $ n - 1) | |
depth :: Nested -> Int | |
depth Empty = 0 | |
depth (Nest xs) = 1 + depth xs | |
demo :: Int -> IO () | |
demo = print . grow | |
main = do demo 1 | |
demo 10 | |
demo 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment