2 ms·
Your pseudo-code is a little weird (it recurses infinitely?) but I think that what you're referring to is memoization, or basically caching your function calls'
by wlievens 17y ago
Your pseudo-code is a little weird (it recurses infinitely?) but I think that what you're referring to is memoization, or basically caching your function calls' results for equivalent arguments. I don't know if any languages support it out the box, but I do know that any language with first-class functions and closures will allow you to make a simple "wrapper" construct so that you get this feature anyway.
- Davertron 17y agoNah, it doesn't actually recurse infinitely, it just looks weird. Here's an example in c: http://codepad.org/Xysob1jS http://codepad.org/Xysob1jS Obviously this is a totally contrived example but you get the idea.