June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
10
Task/Currying/Python/currying-3.py
Normal file
10
Task/Currying/Python/currying-3.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
>>> from functools import partial
|
||||
>>> from operator import add
|
||||
>>> add2 = partial(add, 2)
|
||||
>>> add2
|
||||
functools.partial(<built-in function add>, 2)
|
||||
>>> add2(7)
|
||||
9
|
||||
>>> double = partial(map, lambda x: x*2)
|
||||
>>> print(*double(range(5)))
|
||||
0 2 4 6 8
|
||||
13
Task/Currying/Python/currying-4.py
Normal file
13
Task/Currying/Python/currying-4.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
>>> from toolz import curry
|
||||
>>> import operator
|
||||
>>> add = curry(operator.add)
|
||||
>>> add2 = add(2)
|
||||
>>> add2
|
||||
<built-in function add>
|
||||
>>> add2(7)
|
||||
9
|
||||
>>> # Toolz also has pre-curried versions of most HOFs from builtins, stdlib, and toolz
|
||||
>>>from toolz.curried import map
|
||||
>>> double = map(lambda x: x*2)
|
||||
>>> print(*double(range(5)))
|
||||
0 2 4 6 8
|
||||
Loading…
Add table
Add a link
Reference in a new issue