Python的中缀数据结构
infixp的Python项目详细描述
英菲比
看博客文章, Introducing infixpy: Scala-inspired data structures for Python 了解如何使用此库。
A functional, object-oriented approach for working with sequences and collections. Also similar to Spark RDDs and Java Streams. Hope you find they simplify your code by providing a plethora of common algorithms for working with sequences and collections.
Stephen的直接引自Scala的例子
Scala版本
vala=((1to50).map(_*4).filter(_<=170).filter(_.toString.length==2).filter(_%20==0).zipWithIndex.map{case(x,n)=>s"Result[$n]=$x"}.mkString(" .. "))a:String=Result[0]=20..Result[1]=40..Result[2]=60..Result[3]=80
使用infixpy库和python的版本
^{pr2}$原始示例
frominfixpyimportSeq(Seq(range(10)).map(lambdax:x+3).filter(lambdax:x%2==0).group_by(lambdax:x%3).items().for_each(print))
输出
(1, SList([4, 10])) (0, SList([6, 12])) (2, SList([8]))
示例
有关使用infinexpy的其他示例,请参见examples/directory。
另请参见中的示例用法 career_village_entities。
- 项目
标签: