Skip to main content

Haskell-like intervals for Python

Project description

test codecov

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

# "Forbidden" syntax.
import lange
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.
import lange
print(~[0.4, 0.8, ..., 2])
# [0.4 0.8 1.6]
# Conservative syntax.
from lange_ import g_
print(g_[0.4, 0.8, ..., 2])
# [0.4 0.8 1.6]
pr = g_[0.4, 0.8, ...]
print(pr[:5])
# [0.4 0.8 1.6 3.2 6.4]

Project details


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.22.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

lange-0.2101.22-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file lange-0.2101.22.tar.gz.

File metadata

  • Download URL: lange-0.2101.22.tar.gz
  • Upload date:
  • Size: 6.1 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.55.1 CPython/3.9.1

File hashes

Hashes for lange-0.2101.22.tar.gz
Algorithm Hash digest
SHA256 a39728e84138e55841dc32661f741dd11303f21660f6f49ad8277e8d25b773a0
MD5 fd3ea592e06c1a31fe76006d5011e9bf
BLAKE2b-256 15005cd71d68c79b292fff8d1b9823ff0f3e1e270122b0597450626a9b8944dd

See more details on using hashes here.

File details

Details for the file lange-0.2101.22-py3-none-any.whl.

File metadata

  • Download URL: lange-0.2101.22-py3-none-any.whl
  • Upload date:
  • Size: 19.3 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.55.1 CPython/3.9.1

File hashes

Hashes for lange-0.2101.22-py3-none-any.whl
Algorithm Hash digest
SHA256 2b603e499c2a5d5baba010ca134b7847c36dd6652b360cf56e09553ff879d15d
MD5 913433082ad44bb96d93d3aeda54f734
BLAKE2b-256 81c1b784ec78d96615ef2afbaf20cd09bd7b9f10dc3529f6c2d9a3b2f4ec4bc6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page