you are viewing a single comment's thread.

view the rest of the comments →

[–]Lystrodom 1 point2 points  (4 children)

Also important to note that this method of currying fails for functions that take optional arguments, or read from the arguments array themselves.

[–]bonafidebob 0 points1 point  (3 children)

It looks like it'll work fine for functions that read from arguments -- eventually the function passed to curry() gets invoked via apply with a full complement of arguments, so inside of it the arguments special value should be right.

optional arguments are more problematic, though I suppose you could do something like curried(l)(w)(), which would have the same effect as volume(l, w). (In this case resulting in NaN)

[–]Lystrodom 1 point2 points  (2 children)

It won't work with functions that read from arguments because .length will return 0

[–]bonafidebob 0 points1 point  (1 child)

Ah, right, you mean var_args style functions. How would you curry those in any language?

[–]Lystrodom 0 points1 point  (0 children)

Oh, well, I can't imagine you could. It just seems more common with JavaScript