3 ms·
So it sounds like a monoid is a: Function of arity-2 (possibly expressed as an infix operator) Which is closed over the set of values that are its arguments/p
by Roboprog 9y ago
So it sounds like a monoid is a:
Function of arity-2 (possibly expressed as an infix operator)
Which is closed over the set of values that are its arguments/parameters
For a domain (set of input values) which contains a value that converts the function into an identity function when used.
E.g. -
Addition over real numbers (or integers...), becomes an identity function when one arg is 0
Multiplication over real numbers (or integers...), becomes an identity function when one arg is 1
Something along that line?
I guess that makes it useful for a fold/reduce type function where the final result is the same type as the input stream, and the initial value can be identified as a known default.
- mightybyte 9y agoYep, it sounds like you pretty much have it. In addition to the two examples you mention, here are some other examples of monoids: Lists under concatenation Booleans under AND Booleans under OR Numbers under max Numbers under min
- dllthomas 9y agoExactly right, but for omitting associativity (which, as noted elsewhere, mightybyte skipped).