First page Back Continue Last page Summary Graphic
Special versus general
Sometimes you want to pick out constructs:
- simplify (IfThenElse b x y) =
- if b == constant "True" then x ...
- simplify (Apply f [x]) =
- if f == function "id" then x ...
Sometimes you want generic tree traversal:
- freeVars (Node sym subtrees scope) =
- if null subtrees then set [sym] else
- union (map freeVars subtrees)
The best approach is to arrange for both styles to be as convenient as possible