Semigroup
public protocol Semigroup
Protocol for a semigroup, any algebraic structure that allows two of its elements to be combined into one,
(A, A) -> A, for any of its elements and keeping associativity property for all the cases, for example:
(a1 <> a2) <> a3 = a1 <> (a2 <> a3) for any as in A.
Axioms:
- Totality
- Associativity
For example, having a f(x) -> x and a g(x) -> x, one would be able to compose h = f <> g in a way that the new
function h(x) will be similar to g(f(x))
-
Semigroup combine operation
Declaration
Swift
static func <> (lhs: Self, rhs: Self) -> SelfParameters
lhsFirst semigroup
(A) -> A, let’s call itf(x)rhsSecond semigroup
(A) -> A, let’s call itg(x)Return Value
a composed semigroup
(A) -> Aequivalent tog(f(x))
View on GitHub
Semigroup Protocol Reference