Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created February 14, 2017 21:52
Show Gist options
  • Save deque-blog/e92360ac951533b76747c3b30a4104f4 to your computer and use it in GitHub Desktop.
Save deque-blog/e92360ac951533b76747c3b30a4104f4 to your computer and use it in GitHub Desktop.
countNodes :: Expr -> Int
countNodes = cata countAlg where
countAlg (Op _ xs) = 1 + sum xs
countAlg _ = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment