A functional programming library that aims to supplant Python's existing functional interfaces, offering a more comprehensive and expressive alternative.
Project description
Seittik
Seittik is a functional programming library for Python that aims to supplant Python's existing functional interfaces, offering a more comprehensive and expressive alternative.
Put another way: If you ever wished Python's map
, filter
, and
itertools
had a fluent API, or that lambda
wasn't quite so verbose,
this is for you.
It provides:
- A fluent and extensive API for processing iterable data: pipes.
- A compact and expressive alternative to
lambda
: shears. - A kitchen-sink, all-under-one-roof approach.
- A REPL-first philosophy.
Examples
Something basic:
from seittik import P, X, Y
# Take numbers 1 through 4, triple them, keep evens, and sum them
P([1, 2, 3, 4]).map(X * 3).filter(X % 2 == 0).fold(X + Y)
# 18
# Or, equivalently:
P.range(1, 4).map(X * 3).filter(X % 2 == 0).sum()
# 18
And something more amusing:
import random; random.seed(0) # Get a deterministic result below
from seittik import P, X, Y
# Return 5 arrays of traditional RPG stats (rolling three six-sided dice
# for each of "Str", "Dex", "Con", "Int", "Wis", and "Cha") that have at
# least one score of 14 or better, sorted by the sum of the array, in
# descending order, providing dict labels.
(P.roll('3d6')
.chunk(6)
.filter(P.any(X >= 14))
.dictmap({'sum': sum, 'scores': X})
.take(5)
.sort(key=X['sum'], reverse=True)
.list())
# [{'sum': 71, 'scores': (13, 13, 9, 8, 16, 12)},
# {'sum': 66, 'scores': (14, 10, 8, 13, 9, 12)},
# {'sum': 66, 'scores': (8, 14, 9, 12, 13, 10)},
# {'sum': 57, 'scores': (9, 15, 8, 6, 10, 9)},
# {'sum': 54, 'scores': (12, 7, 5, 14, 6, 10)}]
(These undoubtedly look much nicer on the documentation site.)
Installation
Using Poetry with an existing project:
poetry add seittik
If you're using pip
directly (not recommended):
pip install seittik
Documentation
See seittik.com
License
MIT. See LICENSE.
Changelog
See CHANGELOG.md.
Like it? Support kitties!
If you're able, donations to 4 Paws Sake PA would be enormously appreciated. They're an absolutely wonderful animal rescue.
("Seittik" is "kitties" spelled backwards. I'm a cat person, and I wanted to avoid name collisions.)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file seittik-2023.4.tar.gz
.
File metadata
- Download URL: seittik-2023.4.tar.gz
- Upload date:
- Size: 39.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.10 Linux/6.2.9-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab44c640d16d9576ef000a8d03075e5b0ac78bf1e387e7286ba810a9413211db |
|
MD5 | 1f455733e6906730a158bf294110ae88 |
|
BLAKE2b-256 | a0928a5e676f5370cddccdb3c5d46da82ab218091b775d62b7f6d67268adaaf7 |
File details
Details for the file seittik-2023.4-py3-none-any.whl
.
File metadata
- Download URL: seittik-2023.4-py3-none-any.whl
- Upload date:
- Size: 41.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.10 Linux/6.2.9-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 001f7a979a38d7b3285d2e5b184acc19a9c8ffc0f88b99893e7aca534adec1d5 |
|
MD5 | 6879e7874852d5d946944b6cc53c5733 |
|
BLAKE2b-256 | 111709b6a3cac03cca84b2cf6cd607d4e4c8d117e5b9a059aa15969c682cb100 |