Infix data structures for Python
Project description
ω‰‰alaps
See blog post, Introducing infixpy: Scala-inspired data structures for Python to learn about using this library.
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's Direct from Scala example
Scala version
val a = ((1 to 50)
.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
Version using the infixpy library with python
from infixpy import *
a = (Seq(range(1,51))
.map(lambda x: x * 4)
.filter(lambda x: x <= 170)
.filter(lambda x: len(str(x)) == 2)
.filter( lambda x: x % 20 ==0)
.enumerate() Ï
.map(lambda x: 'Result[%d]=%s' %(x[0],x[1]))
.mkstring(' .. '))
print(a)
# Result[0]=20 .. Result[1]=40 .. Result[2]=60 .. Result[3]=80
Original Example
from infixpy import Seq
(Seq(range(10))
.map(lambda x: x+3)
.filter(lambda x: x%2==0)
.group_by(lambda x: x%3)
.items()
.for_each(print))
Output
(1, SList([4, 10]))
(0, SList([6, 12]))
(2, SList([8]))
Examples
See examples/ directory for additional examples of using infixpy.
Also see example usages in career_village_entities.
Closing Remarks
Very much a work in progress. Expect major changes as the library evolves. I'd appreciate other people's input, so feel free to submit a PR.
Contact: Matt Hagy matthew.hagy@gmail.com
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file infixpy-0.0.3.tar.gz.
File metadata
- Download URL: infixpy-0.0.3.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e67aab4eee8d037ccc3cc5dfeca2949905cc7bb465ec3d11591e52cebb34aac
|
|
| MD5 |
078130b838edbcabd7e313bfb263396b
|
|
| BLAKE2b-256 |
f6c82729930aa8edef6fac5a13ff1bc140b7859fe58d51e586a74bbe982dee38
|
File details
Details for the file infixpy-0.0.3-py3.7.egg.
File metadata
- Download URL: infixpy-0.0.3-py3.7.egg
- Upload date:
- Size: 11.1 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0c1d5bcbec3e4c33ca4b319516197280a8e4082e7f094c2d4d9834c19a87f51
|
|
| MD5 |
f4149715480546b336d0ad6c15c8f88e
|
|
| BLAKE2b-256 |
a26a3a641daf569b8c7f37d3ea54950b6b8c4f94bcd0e7b6ec694beb3f236708
|
File details
Details for the file infixpy-0.0.3-py3-none-any.whl.
File metadata
- Download URL: infixpy-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35f718d1358275d9609d8204f9627f9baa9f761c0971eceb5ed2b7ca50d735ee
|
|
| MD5 |
e35a7157c41c9867fcadff0ab9953e93
|
|
| BLAKE2b-256 |
ed25e8b0753eb6d263cd03a484846378c75ec623a3e3512df24f6b4c07dd677e
|