Haskell-like intervals for Python
Project description
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.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 .+. 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]
"""
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]
"""
Other projects
Please access this website for more information.
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-1.230203.1.tar.gz
(19.6 kB
view details)
Built Distribution
File details
Details for the file lange-1.230203.1.tar.gz
.
File metadata
- Download URL: lange-1.230203.1.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.15.0-58-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e4a346a83588722a15244785be9ce6ed0468767b1208605a0825547aaa0a92b |
|
MD5 | a2acb967633df5009e43014fd0ef4b10 |
|
BLAKE2b-256 | eab6288acecfdbeee5916da980be77da25f6ccc2166daa75c41c1bffe6d8fc0e |
File details
Details for the file lange-1.230203.1-py3-none-any.whl
.
File metadata
- Download URL: lange-1.230203.1-py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.15.0-58-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 182b1182e4931642ce3ede2af40c5c3df9b06b36986a61227ffc660d3822b053 |
|
MD5 | fb43ced0c4b3ec19238b14d93909c7b0 |
|
BLAKE2b-256 | 8c235bd9f7020efb80d4661b5f1ab6c38f168cfac0b5eb1368fcbfb31975479b |