Haskell-like intervals for Python
Project description
lange
Lazy lists (i.e. Haskell-like ranges) for Python.
Features
- Stable floating-point range generation, e.g.:
0.8 - 0.6 == 0.2
up to 28 digits (customizable).
Examples
Arithmetic Progression
# Forbidden syntax.
from lange import *
print(-[0.6, 0.8, ..., 2])
# [0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0]
# Conservative syntax.
from lange_ import a_
print(a_[0.6, 0.8, ..., 2])
# [0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0]
pr = a_[0.6, 0.8, ...]
print(pr[:5])
# [0.6 0.8 1.0 1.2 1.4]
Geometric Progression
# Forbidden syntax.
from lange import *
print(~[0.6, 0.8, ..., 2])
# [0.6 0.8 1.0666666666666667 1.4222222222222223 1.8962962962962964]
# Conservative syntax.
from lange_ import g_
print(g_[0.6, 0.8, ..., 2])
# [0.6 0.8 1.0666666666666667 1.4222222222222223 1.8962962962962964]
pr = g_[0.6, 0.8, ...]
print(pr[:5])
# [0.6 0.8 1.0666666666666667 1.4222222222222223 1.8962962962962964]
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.8.tar.gz
(6.4 kB
view hashes)
Built Distribution
lange-0.2101.8-py3-none-any.whl
(20.5 kB
view hashes)