Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Carnegie Mellon's intro functional programming lectures are now online for free. Parent comment
For instance, here's the SML code for it:
``` datatype exp =
Num of int | Plus of exp * exp | Minus of exp * exp | Times of exp * exp | Div of exp * exp
Implement the function `eval : exp -> int`, which evaluates the expression as best as it can. Assume no division by zero.
Extra credit: Can you implement `eval' : exp -> int option`, that returns `SOME n` if the expression evaluates, and `NONE` if it divides by zero?
There are no comments on this comment yet.
For instance, here's the SML code for it:
``` datatype exp =
```Implement the function `eval : exp -> int`, which evaluates the expression as best as it can. Assume no division by zero.
Extra credit: Can you implement `eval' : exp -> int option`, that returns `SOME n` if the expression evaluates, and `NONE` if it divides by zero?