28 ms·
The other replies are massively overcomplicating things. A monoid is - a set `X` - together with an associative binary operation (let's call it `+`) - and an
by nyssos 3y ago
The other replies are massively overcomplicating things. A monoid is
- a set `X`
- together with an associative binary operation (let's call it `+`)
- and an element (`0`) such that `a + 0 = 0 + a = a` for all elements `a` in `X`.
Monoids are a class of structures, the collection of all arrays of a given type (with concatenation as the monoid operation, and the empty array as its identity element) is a particular example of a monoid.
Other examples include the natural numbers under addition, the integers under multiplication, functions `T => T` under function composition, booleans under and, booleans under or, and strings under concatenation. They're one of the simplest and most common algebraic structures.
- maxk42 3y agoThank you. In ten+ years, I think this is the simplest and clearest explanation I've read.