Skip to content

Instantly share code, notes, and snippets.

@dcolish
Created April 12, 2012 23:52
Show Gist options
  • Select an option

  • Save dcolish/2371969 to your computer and use it in GitHub Desktop.

Select an option

Save dcolish/2371969 to your computer and use it in GitHub Desktop.
data Tree' a = E' | Tree' (Tree' a) a (Tree' a)
foo' = Tree' E' 0 E'
foo = Tree' (Tree' E' 1 E' ) 0 (Tree' E' 1 (Tree' E' 0 E'))
foo'' = Tree' E' 0 (Tree' E' 1 E')
height t = case t of
E' -> 0
Tree' s1 x s2 -> if h1 > h2 then h1 + 1 else h2 + 1
where
h1 = height s1
h2 = height s2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment