Skip to main content

Haskell-like intervals for Python

Project description

test codecov pypi Python version license: GPL v3

API documentation

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 1.2 1.6 2.0]
"""
# Infinite + slicing
prog = ap[0.4, 0.8, ...]
print(prog[:5])
"""
[0.4 0.8 1.2 1.6 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 1.6 3.2 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]
"""

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

Uploaded Source

Built Distribution

lange-0.220727.11-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lange-0.220727.11.tar.gz
  • Upload date:
  • Size: 19.4 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

Hashes for lange-0.220727.11.tar.gz
Algorithm Hash digest
SHA256 2abc6ced2125f4531d0b73d80329543089ea47523fa54597ca7997c7faf97d2a
MD5 3dac621d74f21e4717a81e4cc5802bf4
BLAKE2b-256 d41398b9c5f65752d17b1ee66a35362bf7463da75397c989fe9d769ba393ae50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lange-0.220727.11-py3-none-any.whl
  • Upload date:
  • Size: 23.3 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

Hashes for lange-0.220727.11-py3-none-any.whl
Algorithm Hash digest
SHA256 e62eb93f752ef0b41e5e0f28f3a0ab1f8d25f1dd4afa52b4219ba897b7c138f3
MD5 8eb06c4e3a2ae9231cf3578739505da0
BLAKE2b-256 b795d1ae5867432e0b963e7a53880a9a92e4a7b8fb00ca6489b62de4b6a06ea2

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