Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8db151c

Browse files
Adds monoid description (#7)
1 parent ac896aa commit 8db151c

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

‎README.md‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ __Table of Contents__
3535
* [Lambda Calculus (TODO)](#lambda-calculus-todo)
3636
* [Lazy evaluation (TODO)](#lazy-evaluation-todo)
3737
* [Functor (TODO)](#functor-todo)
38-
* [Applicative (TODO)](#applicative-todo)
3938
* [Applicative Functor (TODO)](#applicative-functor-todo)
40-
* [Monoid (TODO)](#monoid-todo)
39+
* [Monoid](#monoid)
4140
* [Monad (TODO)](#monad-todo)
4241
* [Comonad (TODO)](#comonad-todo)
4342
* [Morphism (TODO)](#morphism-todo)
@@ -588,20 +587,31 @@ object.map(compose(f, g)) ≍ object.map(g).map(f)
588587

589588
## Pointed Functor (TODO)
590589

591-
## Applicative (TODO)
590+
## Applicative Functor (TODO)
591+
592592

593-
## Applicative Functore (TODO)
593+
## Monoid
594594

595-
## Monoid (TODO)
595+
An object with a function that "combines" that object with another of the same type
596+
and an "empty" value, which can be added with no effect.
596597

597-
An object with a function that "combines" that object with another of the same type.
598+
One simple monoid is the addition of numbers
599+
(with `__add__` as an addition function and `0` as an empty element):
600+
601+
```python
602+
>>> assert 1 + 1 + 0 == 2
603+
>>>
604+
```
598605

599-
One simple monoid is the addition of numbers:
606+
Tuples, lists, and strings are also monoids:
600607

601608
```python
602-
1 + 1 # 2
609+
>>> assert (1,) + (2,) + () == (1, 2)
610+
>>> assert [1] + [2] + [] == [1, 2]
611+
>>> assert 'a' + 'b' + '' == 'ab'
612+
>>>
603613
```
604-
In this case number is the object and `+` is the function.
614+
605615

606616
## Monad (TODO)
607617

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /