
28 Jan
2006
28 Jan
'06
1:49 a.m.
BTW: There isn't an easy way to magically derive opTable. We're relying on the fact that these simple functions all have the same type. Ben Lippmeier wrote:
opTable = [ ("+", (+)) , ("-", (-)) ... ]
myeval x y op = let Just fun = lookup op opTable in x `fun` y
You could also do myeval x y op = case op of "+" -> x + y "-" -> x - y ... is probably the "smallest" way. Ben.