0

Has my combinator with the working title curryTuple a common name in the functional community?

const curryTuple = f => tuple =>
  foldl(g => x => g(x)) (f) (tuple);

const triple = [x => y => x + y, 0, [1,2,3,4,5]];

const foldl = f => acc => xs => xs.reduce((x, y) => f(x) (y), acc);

console.log(
  curryTuple(foldl) (triple));

For obvious reasons only within the dynamically typed community :D

1 Answers1

2

It's just called uncurry.

To paraphrase the title question, it's the combinator that takes a curried function and returns an uncurried function (taking a tuple). A combinator that actually takes both the curried function and the tuple at once (and returns the result of the application) would be uncurry(uncurry).

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
  • You're right, but in a sense it is a variadic uncurry, because it works for any tuple. `variadicUncurry` is still hideous. Any suggestions? –  Sep 16 '20 at 15:35
  • Considering your comment the function is too dynamically typed anyway.. –  Sep 16 '20 at 15:38
  • If you name your currying function `variadicCurry` instead of `curry`, you'd do the same for `uncurry` of course. Or you just keep their names, make them work with variadic functions, and supply extra `curryN(2)`/`uncurryN(2)` functions for fixed arities. That's the approach Ramda is taking iirc. – Bergi Sep 16 '20 at 15:43