p'lisp

Try p'lisp in your browser

p'lisp is a Clojure made for a pocket calculator. Here it runs in this page, as one small WebAssembly module. Your code never leaves your browser.

Ctrl+Enter or ⌘+Enter runs it too
Loading p'lisp…

Calling JavaScript from p'lisp

A page gives a script only the functions it chooses. This page registers one, page/roll, with this JavaScript:

p.register('page', 'roll', (sides) => 1 + Math.floor(Math.random() * sides));

p'lisp can then call it like any other function. Press above and run it: the script rolls a die 600 times and counts each face. Arguments come in as plain JavaScript values, and the return value goes back as p'lisp data.

Limits

Every run here gets a budget of one million steps and 256 KB of memory, the same memory the calculator has. A script that runs out stops with a plain error, and the next run starts fresh. Try to see it. A script has no clock, files or network unless the page registers a function for them.

Use it in your own project

The runtime on this page is the npm package @playplisp/plisp. It works in browsers and in Node.

npm install @playplisp/plisp
import { open } from '@playplisp/plisp';

const p = await open({ steps: 1_000_000 });
p.register('page', 'roll', (sides) => 1 + Math.floor(Math.random() * sides));
p.eval('(page/roll 6)'); // a number from 1 to 6

What else to try