Solution to the 99 LISP Problems #9
This was the first challenging problem I encountered in this set. After
spending the first few minutes, I started worrying that this problem may not
fit into a simple recursive solution. I did not want to write a do
or for
loop etc.
What I was looking for was some ingenuously simple recursive solution to this
problem (without the use of a helper or a lambda). After quite a bit of
struggle (and some looking around) I realized there isn’t one (that I could
find, at least). Therefore, I implemented this as a recursive solution by
implementing two new verbs (themselves recursive) specifically for this
problem.