使python具有功能链样式。
fc的Python项目详细描述
使python具有功能链样式。
如何使用?
从PYPI安装:
$ pip install fc
您只需导入Fc,如下所示:from fc import Fc
然后你就可以像kotlin/js:
fromfcimportFcl=(Fc([1,2,3,4,5]).map(lambdax:x+1).filter(lambdax:x>4).print()# [5, 6].map(lambdax:x+1).print()# [6, 7].cat([8,9]).print()# [6, 7, 8, 9].add(10).print()# [6, 7, 8, 9, 10].catHead([1,2,3,4,5]).print()# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].limit(3).done())assertl==[1,2,3]
你可以检查这个test file并了解更多。