Lazy lists (i.e. Haskell-like ranges) for Python. Latest release | Current code | API documentation
# Set up a virtualenv.
python3 -m venv venv
source venv/bin/activate
# Install from PyPI
pip install langecd my-project
git clone https://github.com/davips/lange ../lange
pip install -e ../lange- 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]
Arithmetic Progression
Details
# 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
Details
# 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]
"""Please access this website for more information.