3 ms·
It's a simple expression evaluator evaluating a + 2 * b with a = 1 and b = 2. The fun part is that it's all done using only the one recursive Evaluate function
by grayrest 15y ago
It's a simple expression evaluator evaluating a + 2 * b with a = 1 and b = 2. The fun part is that it's all done using only the one recursive Evaluate function with everything else being driven by the type system and pattern matching. The entire program is also strongly typed with only one type declaration (the env argument to Evaluate).
F# is a neat language. I'm sort of surprised he went with the type system rather than computation expressions/async workflows, which are my favorite feature. They aren't unique (they're monads) but the syntax is nice. I'd happily code in F# if I had a reason to write .NET code.