lange
Lazy lists (i.e. Haskell-like ranges) for Python. Latest release | Current code | API documentation
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.2up 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 .+. 2.0]
"""
# Infinite + slicing
prog = ap[0.4, 0.8, ...]
print(prog[:5])
"""
[0.4 0.8 .+. 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]
"""
# Towards negative.
print(ap[1, -2, ..., -8].l)
"""
[1, -2, -5, -8]
"""
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 .*. 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]
"""
# Using negative step.
print(gp[1, -2, ..., 130].l)
"""
[1, -2, 4, -8, 16, -32, 64, -128]
"""
Other projects
Please access this website for more information.
Metadata
Release files for lange 1.230203.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lange-1.230203.2.tar.gz | 20.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lange-1.230203.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.7 kB
Release files / lange-1.230203.2.tar.gz
| Download URL | lange-1.230203.2.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d9c3f5ae28829f8ab7e6316d65852fce04c31d34d839422b1c978fcaa49dc682
|
|
BLAKE2b-256 checksum How to use checksums |
b494e4fe160b674145175ad05941c295b9314a974de6af9711d22752863e86af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.10.6 Linux/5.15.0-58-generic
|
Release files / lange-1.230203.2-py3-none-any.whl
| Download URL | lange-1.230203.2-py3-none-any.whl |
|---|---|
| Size | 23.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97521b797ed3cbfc81ef7df4c21f55db11e071985b3b7b88426e70b504b81fdb
|
|
BLAKE2b-256 checksum How to use checksums |
284d95e5b3494dbb1e0323f7b793f73329cd3d9189be7f3e0c1edacad93a02bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.10.6 Linux/5.15.0-58-generic
|