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.24.tar.gz
(6.9 kB
view details)
Built Distribution
lange-0.2101.24-py3-none-any.whl
(23.0 kB
view details)
File details
Details for the file lange-0.2101.24.tar.gz
.
File metadata
- Download URL: lange-0.2101.24.tar.gz
- Upload date:
- Size: 6.9 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.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f82df304d5921ef605fa17d7203213e2578cd8e698876991dda2ed2dc6e1e359 |
|
MD5 | 8a37e276353aa4c35592cc91da5fc250 |
|
BLAKE2b-256 | fef471c453cc14c09de54f9a4adb44d87fdf5691d7db2057e4b797976e4bb7e5 |
File details
Details for the file lange-0.2101.24-py3-none-any.whl
.
File metadata
- Download URL: lange-0.2101.24-py3-none-any.whl
- Upload date:
- Size: 23.0 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.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 571ef1da9d66eba1f9d76cb62bd1e0e1e9dfa9239a52ab7cf8a72032d0ee5709 |
|
MD5 | f623fb3651ad165d558a96610ef77f6f |
|
BLAKE2b-256 | 78518e6e12fb914e39a69c3651ce933ebd64cd6292ccec6e702e989e9a7b2fb5 |