3 ms·
It's a tool for constructing recursive functions when the language does not support a function calling itself by name. That happens if, for example, the langua
by cryptonector 3y ago
It's a tool for constructing recursive functions when the language does not support a function calling itself by name. That happens if, for example, the language won't finish compiling the function and making a symbol with its name available for binding/linking until it's done compiling it, so.. in such a case you can't recurse by name. So what to do? Well, you make your recursive function take an extra parameter that is also a function value, and then you'll define a function that calls your wannabe-recursive function with.. itself as the argument function so that it can then call itself as intended.
It's quite simple when thought of that way. "Fixed point" can seem like a high falutin' term of art, and that's because it is -- we love our terms of art, but we also need to be able to explain them.
`fix` then is a function which takes a function value as an argument and which returns a new function value which is a function that calls the argument to `fix` with that same argument as its first argument. Reading that I realize it's hard to express this in pure natural language -- one has to introduce symbols for naming the various functions.