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.2101.23.tar.gz
(6.8 kB
view details)
Built Distribution
lange-0.2101.23-py3-none-any.whl
(19.4 kB
view details)
File details
Details for the file lange-0.2101.23.tar.gz
.
File metadata
- Download URL: lange-0.2101.23.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ecf84463499fde4214855d7ebca51b45fc139c417b9bcdfa6e87d971182dedd |
|
MD5 | 8e3ba3c89f9772252d296ef64d215fb6 |
|
BLAKE2b-256 | 63d00038feecf9b77a6fa7e3ac0d131a83b8f0dd1a7906f93fb54bc3d30183f8 |
File details
Details for the file lange-0.2101.23-py3-none-any.whl
.
File metadata
- Download URL: lange-0.2101.23-py3-none-any.whl
- Upload date:
- Size: 19.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41bfc4921cfe183c3d75e904bc840a762326b9fbf53d92f6efa4e058f3047965 |
|
MD5 | 71be4d3879a285e1ced0f188eaf0eefd |
|
BLAKE2b-256 | 20238794abfb24be833de41cbf5cbd8d2f0c216c9eea10e4fcfe9879fdc64bbd |