Max Smirnov
Max Smirnov

Reputation: 603

Phi combinator in Scala

Is there a Phi combinator (also known as on function from Haskell) in Scala?

Upvotes: 0

Views: 106

Answers (1)

Gaël J
Gaël J

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

Related Questions