creamidea / Mushroom

To display Node Capture Data and Control it
Other
0 stars 1 forks source link

python 函数式编程 #13

Open creamidea opened 10 years ago

creamidea commented 10 years ago

Currying: partial function application PFA

举一个栗子:

>>> baseTwo = partial(int, base=2)
>>> baseTwo.__doc__ = 'Convert base 2 string to an int.'
>>> baseTwo('10010')
creamidea commented 10 years ago

(Let me think of Lisp, My dear lisp)

t1anchen commented 10 years ago

不知道问题是什么……

>>> from functools import partial
>>> basetwo = partial(int, base=2)
>>> basetwo.__doc__ = 'Convert base 2 string to an int.'
>>> basetwo('10010')
18
creamidea commented 10 years ago

@au9ustine

嗯,其实这里的issue被我滥用了,这里也变成记笔记的地方了,不仅仅记录问题。

自问自答,自娱自乐:)

t1anchen commented 10 years ago

不过说来,python最大的好处是可读性比较好。函数式的功能不多,也足够用了。