# Semigroup

``public protocol Semigroup``

A semigroup is an algebraic structure that consists of a set of values and an associative operation.

• ``` combine(_:) ```

An associative operation to combine values of the implementing type.

This operation must satisfy the semigroup laws:

``````a.combine(b).combine(c) == a.combine(b.combine(c))
``````

#### Declaration

Swift

``func combine(_ other: Self) -> Self``

#### Parameters

 ``` other ``` Value to combine with the receiver.

#### Return Value

Combination of the receiver value with the parameter value.

• ``` combine(_:_:) ``` Extension method

Combines two values of the implementing type.

#### Declaration

Swift

``static func combine(_ a: Self, _ b: Self) -> Self``

#### Parameters

 ``` a ``` Value of the implementing type. ``` b ``` Value of the implementing type.

#### Return Value

Combination of `a` and `b`.

• ``` combineAll(_:) ``` Extension method

Combines a variable number of values of the implementing type, in the order provided in the call.

#### Declaration

Swift

``static func combineAll(_ elems: Self...) -> Self``

#### Parameters

 ``` elems ``` Values of the implementing type.

#### Return Value

A single value of the implementing type representing the combination of all the parameter values.

• ``` combineAll(_:) ``` Extension method

Combines an array of values of the implementing type, in the order provided in the call.

#### Declaration

Swift

``static func combineAll(_ elems: [Self]) -> Self``

#### Parameters

 ``` elems ``` Array of values of the implementing type.

#### Return Value

A single value of the implementing type representing the combination of all the parameter values.