Skip to content

A very simple Lisp implementation in Python. Aims to be didactic rather than fantastic.

Notifications You must be signed in to change notification settings

FredrikMeyer/pylisp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

(yet another) Python Lisp

codecov

See fredrikmeyer.net/pylisp/ for a literate style documentation.

Installation

Run pip install --editable .. There are no dependencies.

Run tests with pytest, and linting with flake8 .

Usage

>  python pylisp/repl.py
Welcome to pylisp.
>((lambda (x) (+ 2 x)) 5)
7.0
>

Or pipe text:

> echo '(+ 1 2)' | plsp
3.0

Factorial function

> python pylisp/repl.py
Welcome to pylisp.
>(define f (lambda (x) (if (< x 2) x (* x (f (dec x))))))
>(f 7)
5040.0

Built-ins

  • lambda
  • define
  • +, and *, <, =, dec
  • if
  • doc (docstring for built-ins)
  • car

Want to Have

  • Multiple args
  • Simple math functions. Maybe import from Python?
  • Quotes
  • Macros
  • Read from file

Installing Python

I use pyenv to manage Python versions.

Install Python 3.11.1:

pyenv install 3.11.1

Build Docs

Docs are built with pycco. Build them by running pip install pycco and pycco pylisp/*.py. I use a simple search-replace to make eval.py the index page.

Similar projects

About

A very simple Lisp implementation in Python. Aims to be didactic rather than fantastic.

Topics

Resources

Stars

Watchers

Forks

Languages