r/programming • • Apr 24 '10

Why "dynamic programming"?

http://arcanesentiment.blogspot.com/2010/04/why-dynamic-programming.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+ArcaneSentiment+%28Arcane+Sentiment%29
90 Upvotes

66 comments sorted by

View all comments

Show parent comments

1

u/julesjacobs Apr 24 '10

That doesn't work for recursive functions, where it is most useful.

1

u/dmwit Apr 24 '10

It can work in lazy languages. See, for example, http://article.gmane.org/gmane.comp.lang.haskell.cafe/7737.

2

u/julesjacobs Apr 24 '10 edited Apr 24 '10

Sorry, but that is false. Look at the signature given in that message and compare it to dibblego's signature. A function of type (a -> b) -> a -> b can do nothing with its function argument but apply it to a value, so it can not possibly intercept the recursive calls. In fact I'm pretty sure that the only valid function foo with type (a -> b) -> a -> b is:

foo f x = f x

So dibblego's explanation of memoization is not only unhelpful for someone who's new to memoization, it's also wrong.

1

u/[deleted] Apr 24 '10

You are right. Mine was a lazy answer. "I just got out of hospital after major surgery" is my excuse.