Phi combinator in Scala

78 views Asked by At

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

1

There are 1 answers

1
Gaël J On

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))