8000 Update README.md · bitnom/functional-jargon-python@f13f042 · GitHub
[go: up one dir, main page]

Skip to content

Commit f13f042

Browse files
authored
Update README.md
1 parent 707a652 commit f13f042

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ __Table of Contents__
1919
* [Continuation (TODO)](#continuation-todo)
2020
* [Side effects](#side-effects)
2121
* [Purity](#purity)
22-
* [Idempotent (TODO)](#idempotent-todo)
22+
* [Idempotent](#idempotent)
2323
* [Point-Free Style (TODO)](#point-free-style-todo)
2424
* [Predicate (TODO)](#predicate-todo)
2525
* [Contracts (TODO)](#contracts-todo)
@@ -189,24 +189,26 @@ input values, and does not produce any side effects.
189189
This function is pure:
190190

191191
```python
192-
def add(first: int, second: int) -> int:
193-
return first + second
192+
>>> def add(first: int, second: int) -> int:
193+
... return first + second
194194
```
195195

196196
As opposed to each of the following:
197197

198198
```python
199-
def add_and_log(first: int, second: int) -> int:
200-
print('Sum is:', first + second) # print is a side effect
201-
return first + second
199+
>>> def add_and_log(first: int, second: int) -> int:
200+
... print('Sum is:', first + second) # print is a side effect
201+
... return first + second
202202
```
203203

204-
## Idempotent (TODO)
204+
## Idempotent
205205

206-
A function is idempotent if reapplying it to its result does not produce a different result.
206+
A function is idempotent if reapplying it to its result does not produce a different result:
207207

208208
```python
209-
# TODO
209+
>>> assert sorted([2, 1]) == [1, 2]
210+
>>> assert sorted(sorted([2, 1])) == [1, 2]
211+
>>> assert sorted(sorted(sorted([2, 1]))) == [1, 2]
210212
```
211213

212214
## Point-Free Style (TODO)

0 commit comments

Comments
 (0)
0