Python 代码
def parse(self, data):
tmp = data
# funcs is a callable function iterator
for func in funcs:
tmp = func(tmp)
return tmp
1
yeyuexia 2017-03-08 17:19:12 +08:00 1
reduce(lamda x, y: y(x), funcs, data)
|
2
staticor 2017-03-08 18:40:33 +08:00
递归实现 判断 funcs
|
3
eccstartup 2017-03-08 20:34:43 +08:00
funs = [(+1),(*2),(subtract 3)]
f = foldr (flip (.)) id funs f 1 |
4
zungmou OP @eccstartup 您这不是 Python 代码呀
|
5
zhzy0077 2017-03-08 21:13:51 +08:00 via Android 1
(fold-left (λ (tmp, func) (func tmp)) data funcs)
|