Skip to content

Instantly share code, notes, and snippets.

@wolverian
Created September 30, 2014 13:18
Show Gist options
  • Save wolverian/f505dd100ad0d8045692 to your computer and use it in GitHub Desktop.
Save wolverian/f505dd100ad0d8045692 to your computer and use it in GitHub Desktop.
#lang typed/racket
(define-type Tree (U leaf node))
(struct: leaf ([val : Number]))
(struct: node ([left : Tree] [right : Tree]))
(: tree-height (-> Tree Integer))
(define (tree-height t)
(match t
[(leaf v) 1]
[(node l r) (max (tree-height l) (tree-height r))]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment