home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-12-30 | 419 b | 15 lines | [TEXT/R*ch] |
- structure Tree : FORMULA =
- struct
- datatype formula = NUM of int
- | CELLREF of formula * formula
- | BINOP of (int*int->int) * formula * formula
- | IF of formula * formula * formula
- fun eval f a =
- let fun g (NUM i) = i
- | g (CELLREF(x,y)) = a sub (g x) sub (g y)
- | g (BINOP(p,x,y)) = p(g x, g y)
- | g (IF(x,y,z)) = if g x <> 0 then g y else g z
- in g f
- end
- end
-