Skip to main content

A minimalist Lisp-inspired language

Project description

🐑 Lambdora

codecov Python License

A ~2-kLOC Lisp-inspired functional language written in modern Python. Lambdora implements a full interpreter—lexer, parser, evaluator, and macro system in a compact codebase.

Lambdora REPL

Features

  • First-class anonymous functions with currying
  • Lexical closures (static scope)
  • Tail-call optimization via trampoline
  • Hygienic macro system (defmacro) for metaprogramming
  • Built-in data types: numbers, booleans, pairs/lists, nil
  • Expressive functional standard library (map, foldl, range, …)
  • Interactive REPL & script runner
  • ~85% test coverage with pytest and Codecov integration

What's New in 1.7.1

  • REPL multiline editing is more robust:
    • Use \b to remove the previous line in multiline mode.
    • Type exit or quit at any point in multiline mode to cancel and return to the main prompt.
    • The multiline prompt is now always ... for clarity.
  • Custom standard library path:
    • Use --stdlib-path to specify a custom standard library file for the REPL or runner:
      lambdora repl --stdlib-path=my_stdlib.lamb
      lambdora run --stdlib-path=my_stdlib.lamb myscript.lamb
      
  • REPL help improvements:
    • The help command now documents all special commands, including \b and multiline exit/cancel.

Quick Start

Web REPL

Try Lambdora in your browser!

No installation required - runs entirely in your browser using WebAssembly.

Local Installation

# Install from PyPI
$ pip install lambdora

# OR install from source
$ git clone https://github.com/ferecci/Lambdora.git && cd Lambdora
$ pip install -e .
# OR
$ make install

# launch REPL
$ lambdora repl

# run a script
$ lambdora run examples/fizzbuzz.lamb

# check version and help
$ lambdora --version
$ lambdora --help

Legacy commands still work:

$ python -m lambdora.repl
$ python -m lambdora.runner examples/fizzbuzz.lamb

Hello World

(print "Hello, Lambdora!") ; => Hello, Lambdora!

Usage Examples

(define inc   (lambda x. (+ x 1)))
(define twice (lambda f. (lambda x. (f (f x)))))
((twice inc) 3)               ; => 5

(defmacro when (cond body)
  (if cond body nil))
(when true (print "hi"))      ; => hi

Examples

Try the included examples:

Architecture Overview

src/lambdora/
  tokenizer.py       # lexical analysis
  parser.py          # S-expression → AST
  evaluator.py       # evaluator with tail-call optimisation
  macro.py           # macro expander & hygiene
  builtinsmodule.py  # built-in functions
  stdlib/std.lamb    # functional standard library

Each module is <200 LOC and unit-tested, making the codebase easy to navigate and extend.

Testing

# install dev dependencies
$ pip install -e .[dev]

# run test-suite & watch coverage
$ pytest --cov  # reports to terminal

A GitHub Action uploads coverage to Codecov (badge above).

Documentation

Contributing

Open an issue or pull request, everyone's welcome! See CONTRIBUTING.md for development guidelines.

License

MIT © Felipe Tancredo (ferecci)

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

lambdora-1.8.0.tar.gz (36.0 kB view details)

Uploaded Source

Built Distribution

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

lambdora-1.8.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file lambdora-1.8.0.tar.gz.

File metadata

  • Download URL: lambdora-1.8.0.tar.gz
  • Upload date:
  • Size: 36.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for lambdora-1.8.0.tar.gz
Algorithm Hash digest
SHA256 44b14de62846905d1db2ac7fb12a8f96cb464a9e7053f8cebcc8baac47844878
MD5 8ceb954e29d2b792f9ea47eca766ecb8
BLAKE2b-256 2f489018e86b8e45ed10d7b8f603fbc450a3f7595b9a2a319acdd89bbf35262b

See more details on using hashes here.

File details

Details for the file lambdora-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: lambdora-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for lambdora-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f62af1ff0e4bad26f41725b283115c4a4ad7606cf167982cbb707f7203962dde
MD5 b1bf1d76720e0b6685d61e7728fe06b2
BLAKE2b-256 2ff29548b0481c97d649c394f0b9976212230314d76a7c741ffd5ccf922a46de

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