All Downloads are FREE. Search and download functionalities are using the official Maven repository.

beaker.common.util.Relation.scala Maven / Gradle / Ivy

The newest version!
package beaker.common.util

import scala.language.implicitConversions

/**
 * A binary relation. Relations are reflexive (x ~ x) and symmetric (x ~ y -> y ~ x).
 */
trait Relation[-T] {

  /**
   * Returns whether or not x and y are related.
   *
   * @param x An element.
   * @param y Another element.
   * @return Whether or not x and y are related.
   */
  def related(x: T, y: T): Boolean

}

object Relation {

  // All elements are related.
  val Total: Relation[Any] = (x, y) => true

  // All elements are unrelated.
  val Identity: Relation[Any] = (x, y) => x == y

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy