add doc for functional

This commit is contained in:
Prodesire 2018-02-11 00:08:47 +08:00
parent 6efa2bb6ce
commit 727cb6b415
2 changed files with 21 additions and 0 deletions

20
docs/functional.rst Normal file
View File

@ -0,0 +1,20 @@
Functional
----------
.. py:function:: pydu.functional.compose(*funcs)
Compose all functions. The previous function must accept one argument,
which is the output of the next function. The last function can accept
any args and kwargs.
compose(f1, f2, f3)(*x) is same to f1(f2(f3(*x))).
>>> from pydu.functional import compose
>>> def f1(a):
... return a+1
...
>>> def f2(a, b=2):
... return a+b
...
>>> compose(f1, f2)(1, b=3)
5

View File

@ -28,6 +28,7 @@ Content
dict
environ
exception
functional
inspect
iter
list