Note that there are very systematic and natural ways to derive dynamic
programming algorithms in functional languages. In a sense, much of the
work of R. Bird centers this topic. The book "Algebra of Programming"
http://web.comlab.ox.ac.uk/oucl/research/pdt/ap/pubs.html#Bird-deMoor96:Algebra
is one of the cornerstones.
The systematic derivation of dynamic programming algorithms has been
rediscovered in a more direct but less general fashion
http://bibiserv.techfak.uni-bielefeld.de/adp/
Thanks a lot for providing the links! Interesting stuff! And also many
thanks for the examplary implementation. This is really enlightening.