4 ms·
Id don't know when this us useful. Also, what does `recurse()()()` mean? What are we looking for exactly?
by abhishekjha 9y ago
Id don't know when this us useful.
Also, what does `recurse()()()` mean? What are we looking for exactly?
- dagw 9y agoin general `f()()` means call the function returned by f() with no arguments. So f()()() means call the function returned by f()() with no arguments. In this case recurse() returns itself so recurse == recurse()()()()... It's more of an interesting observation than anything useful The syntax can occasionally be useful if you have a function the generates function, but then you'd be calling initial function with some argument like this: f_x = f(x)() f_y = f(y)()
- y4mi 9y agowell "recurse" returns an object, "()" executes the returned object. As that execution returns an executeable object as well, you can just start to chain the "()"s ad infinitum. its just abusing a core mechanic.
- fwdpropaganda 9y agoMeans "take the function recurse, execute it, then take the thing it returns and execute that, and then take the thing that returns and execute that."
- abhishekjha 9y agoAny scenario where it is useful to do so?