Skip to content

Instantly share code, notes, and snippets.

@eMdOS
Last active May 11, 2020 17:31
Show Gist options
  • Save eMdOS/bf05d2d439e177e51822e9aa8a90c0c6 to your computer and use it in GitHub Desktop.
Save eMdOS/bf05d2d439e177e51822e9aa8a90c0c6 to your computer and use it in GitHub Desktop.
public extension AssociativeLaw where Element: Semigroup {
///
/// It verifies if the set of elements are **associative** through Semigroup's composition (`<>`).
///
/// The `<>` operator is used to express associativity in an abstract way.
/// This is because elements can either be associative through *addition* (`+`) or through *multiplication* (`*`).
///
/// - Parameters:
/// - a: The first semigroup element
/// - b: The second semigroup element
/// - c: The third semigroup element
///
static func verify(a: Element, b: Element, c: Element) -> Bool {
verify(a: a, b: b, c: c, operation: <>)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment