Reputation: 603
Is there a Phi combinator (also known as on
function from Haskell) in Scala?
Upvotes: 0
Views: 106
Reputation: 15275
Not that I'm aware of but it's fairly easy to implement. For instance:
def on[A, B](f: A => B)(combine: (B, B) => B): (A, A) => B =
(x: A, y: A) => combine(f(x), f(y))
Upvotes: 3