I’m making my way through the The book of F# and been playing with implementing the RPN calculator
personally I found it quite interesting to see my choices during this small exercise, especially the use of Option types to handle error cases comes quite naturally. Another interesting thing I found was that, similar to how I would write the same thing in Lisp, it is very obvious to define functions inside other functions to hide implementation details I would like to give a name to but don’t want to share with the rest of the program.
2 thoughts on “Some F# fun”
You can use List.tryHead instead of your extractResult function.
Mh sadly not, because that would cause a stack with `x :: y :: ` to return `x` even so it should be `None` meaning that `1 2 3` would evaluate to `3` instead of `None`. At least this is my understanding of RPN meaning only a 1 element stack at the end constitues a valid result, I might be wrong so.