2 ms·
I think a lot of tree code is good for practical recursive examples. Of course, it really helps to have algebraic types and pattern matching because they more
by tikhonj 12y ago
I think a lot of tree code is good for practical recursive examples.
Of course, it really helps to have algebraic types and pattern matching because they more clearly expose the recursive structure of both trees and tree-based algorithms. I've also found that writing things out in a patter-matching style, case by case, really helps convey how to think recursively. Instead of trying to run a recursive algorithm in my head, having the separate cases separate makes it easier to consider them one by one.
- egonschiele 12y agoAgreed! I snuck a small Haskell example into my book to show the advantages of pattern matching:)