🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

oa-utils

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oa-utils

Statically typed Python utilities for functional programming.

pipPyPI
Version
0.1.21
Maintainers
1

oa-utils

Statically typed Python utilities for functional programming.

Pipeline

This class is useful for programming in the collection pipeline style. It wraps a homogenous variadic tuple and exposes a fluent interface with common functional programming operations. Why a tuple and not a "lazy" iterator? Because a tuple is relatively immutable and because, in my opinion, reified collections are much easier to reason about than stateful iterators (at the expense of performance).

from oa_utils import Pipeline

hamming_distance = (
    Pipeline("karolin") # ('k', 'a', 'r', 'o', 'l', 'i', 'n')
    .zip_with(lambda a, b: int(a != b), "kathrin") # (0, 0, 1, 1, 1, 0, 0)
    .sum() # 3
)

See pipeline.py for docstrings and doctests of every method.

Keywords

utilities

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts