Skip to content

Instantly share code, notes, and snippets.

@mwotton
Created March 9, 2017 16:41
Show Gist options
  • Save mwotton/62185dd7b2a74671d703fd4a3b994664 to your computer and use it in GitHub Desktop.
Save mwotton/62185dd7b2a74671d703fd4a3b994664 to your computer and use it in GitHub Desktop.
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