3 ms·
What do you mean by this, One little problem: How are we going to pass our function to itself? ? You just pass the function as a parameter to call, like this:
by dhugiaskmak 15y ago
What do you mean by this, One little problem: How are we going to pass our function to itself? ?
You just pass the function as a parameter to call, like this:
sum_of_nested_list.call(sum_of_nested_list, [1,[2,3]])
Right? What am I missing?
- raganwald 15y agoAgain, that depends on binding the function to the name. If that binding changes (as in the example given where some logging is added), things break. Also, being able to do with completely anonymously allows you to use a recursive lambda anywhere you can use a lambda or a block, something that is not currently possible without making a combinator. There’s a practical example of using the Y-COmbinator to make auto-vivifying hash tables in one of the links.
- dhugiaskmak 15y agoGot it, thanks. I was confused because I took that sentence to mean that it wasn't possible to pass the function to itself.