Skip to main content

A basic package for parsing lisp-like linked lists in Python.

Project description

version last_commit license

llll

Python support for lisp-like linked lists (llll).

Key Features

  • Read/write operations in both text (.txt) and native (.llll) formats.
  • 1-based indexing following the bach library and bell language conventions.
  • Element-wise arithmetic with automatic broadcasting.
  • Flexible mapping with depth control.
  • Address and key syntax support for data access and assignment.
  • Fraction support for exact rational arithmetic.

Installation

pip3 install llll-py

Basic Usage

Creating lllls

from llll import llll

# Atomic values
x = llll(42)      # 42
y = llll("hello") # hello

# Nested lists
z = llll(1, 2, [3, 4], 5)  # 1 2 [ 3 4 ] 5

# From Python objects
data = llll.from_python([1, [2, 3], 4]) # 1 [ 2 3 ] 4

File I/O

# Save to file
l = llll(1, 2, [3, 4])
l.write("data.txt")      # Human-readable format
l.write("data.llll")     # Native llll format

# Load from file
from_txt = llll.read("data.txt")
from_llll = llll.read("data.llll")
print(l == from_txt == from_llll) # True

Indexing

llll uses 1-based indexing by convention:

l = llll(10, 20, [30, 40], 50)

l[1]      # 10
l[-1]     # 50
l[3]      # 30 40
l[3, 2]   # 40 (address-based access)

# Slicing (1-based, inclusive)
l[2:3]    # 20 [ 30 40 ]

Keys

Access and modify lllls via keys:

l = llll(["name", "Alice"], ["age", 33], ["parents", "Bob", "Chloe"])

# Access by key
l["name"]         # "Alice"
l["age"]          # 33
l["parents"]      # "Bob" "Chloe"

# Assignment by key
l['name'] = "John"
l['age'] = 55
l['parents'] = ["Geoffrey", "Ada"]
# [ name John ] [ age 33 ] [parents Geofrrey Ada ]

Arithmetic Operations

Element-wise operations with broadcasting:

l = llll(1, 2, 3)

l + 10              # 11 12 13
l * llll(2, 3, 4)   # 2 6 12
l / 2               # 1/2 1 3/2 (returns Fractions for int division)

# Nested operations
nested = llll([1, 2], [3, 4])
nested + 10      # [ 11 12 ] [ 13 14 ]

Mapping

Apply functions at specific depths:

l = llll(1, [2, 3], [[4, 5], 6])

# Boolean comparison
l.map(lambda x, addr: int(x > 2))
# 0 [ 0 1 ] [ [ 1 1 ] 1 ]

# Apply only at depth 2
l.map(lambda x, addr: x * 10,
      mindepth=2,
      maxdepth=2)
# 1 [ 20 30 ] [ [ 4 5 ] 60 ]

The mapping function receives both the value and its address (tuple of indices).

Utility Methods

l = llll(1, [2.5, 3])

l.depth()         # 2
l.to_python()     # [1, [2.5, 3]]
l.append([4, 5])  # 1 [ 2.5 3 ] [ 4 5 ]
l.extend([4, 5])  # 1 [ 2.5 3 ] 4 5
l.as_float()      # 1.0 [ 2.5 3.0 ] 4.0 5.0
l.as_int()        # 1 [ 2 3 ] 4 5

License

MIT License - Copyright © 2025 Felipe Tovar-Henao

Development setup

Follow these steps if you intend to run and/or build llll-py from source.

  1. Install Miniconda.
  2. In the terminal, run:
conda env create -f environment.yml
conda activate llll

To build or publish, run:

hatch build
hatch publish

To run unit tests run:

pytest tests

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

llll_py-0.1.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llll_py-0.1.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file llll_py-0.1.1.tar.gz.

File metadata

  • Download URL: llll_py-0.1.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"arm64","distro":{"name":"macOS","version":"26.4"},"implementation":{"name":"CPython","version":"3.10.20"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.5.6 7 Apr 2026","python":"3.10.20","system":{"name":"Darwin","release":"25.4.0"}} HTTPX2/2.3.0

File hashes

Hashes for llll_py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3ef666de3d79e10dcdae1706ccdcfae0623e9219dbc79f9a2f2cc277375baeca
MD5 61059c3992664ca459237eeae702879e
BLAKE2b-256 be4034e25bde64d58b05f2fdcfe48c0f6bb45aab1d3b8ed87688b661a57f89d7

See more details on using hashes here.

File details

Details for the file llll_py-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: llll_py-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"arm64","distro":{"name":"macOS","version":"26.4"},"implementation":{"name":"CPython","version":"3.10.20"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.5.6 7 Apr 2026","python":"3.10.20","system":{"name":"Darwin","release":"25.4.0"}} HTTPX2/2.3.0

File hashes

Hashes for llll_py-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52c459eb1fd78177968e654ced84e4dc3aef0850213f0206904477726398e6ff
MD5 a4cc6efbb5fb609a8a712017e150b419
BLAKE2b-256 d6435b561d547ff8f1476cb25ef90d5840303ba2ac56e8510ab6461ba6127873

See more details on using hashes here.

Supported by

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