In C, you can have a static variable within a method, which can remember values to which it was set by previous calls of the method. I heard that the same effect can be found by using continuations within Scheme. Can anyone show me how to create the similar effect of a static variable for a function in Scheme without using mutation?
Share
You don’t need continuations for that. Here’s a classic example:
And here’s an obvious generalization to make it more interesting:
And here’s the first piece of code translated to JS: