Haskell-like intervals for Python
Project description
lange
Lazy lists (i.e. Haskell-like ranges) for Python.
Installation
from package
# Set up a virtualenv.
python3 -m venv venv
source venv/bin/activate
# Install from PyPI
pip install lange
from source
cd my-project
git clone https://github.com/davips/lange ../lange
pip install -e ../lange
Features
- Stable floating-point range generation, e.g.:
0.8 - 0.6 == 0.2
up to 28 digits (customizable). - Infinite
[1 2 ...]
or bounded. - O(1) access/evaluation
lst[3443]
Examples
Arithmetic Progression
# Bounded
from lange import ap
print(ap[0.4, 0.8, ..., 2])
"""
[0.4 0.8 1.2 1.6 2.0]
"""
# Infinite + slicing
prog = ap[0.4, 0.8, ...]
print(prog[:5])
"""
[0.4 0.8 1.2 1.6 2.0]
"""
# As list
print(list(prog[:5]))
"""
[0.4, 0.8, 1.2, 1.6, 2.0]
"""
print(prog[:5].l)
"""
[0.4, 0.8, 1.2, 1.6, 2.0]
"""
Geometric Progression
# Bounded
from lange import gp
print(gp[0.4, 0.8, ..., 2])
"""
[0.4 0.8 1.6]
"""
# Infinite + slicing
prog = gp[0.4, 0.8, ...]
print(prog[:5])
"""
[0.4 0.8 1.6 3.2 6.4]
"""
# As list
print(list(prog[:5]))
"""
[0.4, 0.8, 1.6, 3.2, 6.4]
"""
print(prog[:5].l)
"""
[0.4, 0.8, 1.6, 3.2, 6.4]
"""
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
lange-0.220727.5.tar.gz
(19.3 kB
view details)
Built Distribution
File details
Details for the file lange-0.220727.5.tar.gz
.
File metadata
- Download URL: lange-0.220727.5.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.5 Linux/5.15.0-33-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37e47651fe3ea6b0b0684481c71c8ee2e6faba2ea4b84d099dcff365ea194894 |
|
MD5 | 880785857d9bda33e19790d079680ed5 |
|
BLAKE2b-256 | 062b1ed1f438947a94eb493cb07a382d82aefa792295fc0b081140f454cf1d96 |
File details
Details for the file lange-0.220727.5-py3-none-any.whl
.
File metadata
- Download URL: lange-0.220727.5-py3-none-any.whl
- Upload date:
- Size: 23.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.5 Linux/5.15.0-33-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 744540d56d2a8601c7aebad656ae9339583cfb1e0dc7787dcbefbdc70b6e8e07 |
|
MD5 | ea57ec33d179e05dba1a9c043d3b1a79 |
|
BLAKE2b-256 | e9a588c7718ed4e56c380cf9c36c2688618129e05dda6357d24db31d5deeeff0 |