Skip to main content

A functional interface for python iterator

Project description

functionalstream

Installation

pip install functionalstream

Example

Stream

from functionalstream import Stream

# lst1 = [0, 6, 12, 18, 24]
lst1 = Stream(range(10)).filter(lambda x: x % 2 == 0).map(lambda x: x * 3).to_list()

# lst2 = [(1, 2), (3, 4)]
lst2 = Stream([(1,2), (3,4), (6,5)]).filter(lambda x, y: x < y, star=True).to_list()

# array = array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])
array = Stream(range(10)).to_numpy_array(dtype=float)

# for function which has side effect
Stream(range(10)).apply(lambda x: print(x))

PathStream

from functionalstream import PathStream

video_paths = PathStream.from_path('./').filter_extension(extensions={".jpeg"})

Pipeline

from functionalstream.functions import increment
from functionalstream import Stream

# x = 3
x = Stream([increment] * 3).pipeline(0)

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

functionalstream-0.1.8.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

functionalstream-0.1.8-py3-none-any.whl (6.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page