ToolzPython 函数式编程工具箱
Toolz 是 Python 的函数式编程工具箱。Toolz 支持 Python 2.6+ 和 Python 3.3+。
Toolz 的实现包括三部分:
-
itertoolz
,for operations on iterables. 例如:groupby
,unique
,interpose
, -
functoolz
, for higher-order functions. 例如:memoize
,curry
,compose
-
dicttoolz
, for operations on dictionaries. 例如:assoc
,update-in
,merge
.
示例:
>>> def stem(word): ... """ Stem word to primitive form """ ... return word.lower().rstrip(",.!:;'-\"").lstrip("'\"") >>> from toolz import compose, frequencies, partial >>> wordcount = compose(frequencies, partial(map, stem), str.split) >>> sentence = "This cat jumped over this other cat!" >>> wordcount(sentence) {'this': 2, 'cat': 2, 'jumped': 1, 'over': 1, 'other': 1}
评论
浅析函数式编程
函数式编程 1. 函数 高中一年级,应该是最早接触函数这个概念的时间,印象很深刻,毕竟是高考压轴大题,但它却是必修一第二章的内容。 我们来看一个必修一中最简单的一个函数: 上面的函数由三个部分组成: x 自变量...
MakerStack
0
《函数式编程指南》
《函数式编程指南》是使用JavaScript进行函数式编程的书籍,告诉大家如何在日常工作中更好的利用函数式编程的特性。Part1Chapter1:Whateverarewedoing?Introduc
《函数式编程指南》
0
SwiftzSwift函数式编程
Swiftz是一个Swift库,实现了函数式编程。示例代码:let xs = [1, 2, 0, 3, 4]// we can use the Min semigroup to find the mi
SwiftzSwift函数式编程
0
F#函数式编程语言
F#是由微软发展的为微软.NET语言提供运行环境的程序设计语言,是函数编程语言(FP,FunctionalProgramming),函数编程语言最重要的基础是LambdaCalculus。它是基于OC
F#函数式编程语言
0