Open guillaumearm opened 6 years ago
legitimate.
The Haskell implementation of On
is const on = curry((f, g, x, y) => g(f(x), f(y)));
.
However, I would not use the comma to separate the terms, I would rather write it this way:
const on = curry((f, g, x, y) => f(g(x))(g(y));
See a PHP implementation here.
Thanks for your comment. fantasy-land combinators defines psi combinator as following:
const psi = curry((f, g, x, y) => f(g(x))(g(y)));
It's almost the same as your suggested signature, but the order of execution of f
and g
is reversed. Any idea why that is?
You're right, my comment was wrong. I updated it.
The correct implementation is: const on = curry((f, g, x, y) => f(g(x))(g(y));
Please see #250 and http://hackage.haskell.org/package/base-4.10.1.0/docs/Data-Function.html#v:on
implementation idea :