April Koan Night, Polynomial Parser
Details
For our April meetup, we are having another koan night. This time, its a parsing exercise that is open ended so you're free to go as far with it as you like.
The challenge is to implement a Polynomial Parser. So the solution should take a polynomial (https://en.wikipedia.org/wiki/Polynomial) string as input and produce an abstract representation of the polynomial.
For example the string "43x^3 - 23x^2 + 10x - 8" could output
[Term (43,"x",3); Term (-23,"x",2); Term (10,"x",1); Const -8]
with Term being (in F# for example) a discriminated union,
type Term = Term of int * string * int | Const of int
The abstract representation is totally up to you though and doesn't have to be a discriminated union/algebraic data type.
The implementation can be anything from regex to parser combinators and it can go further than parsing, if you so choose, and become some form of an equation solver. Its just about having fun and seeing all the different ways that we can handle string processing with our favourite FP languages :)
Hope to see everyone there - there will be pizza as usual!
