LISP 1.5(-ish) implementation in WebAssembly
Try demo page.
> (car '(a b c))
A
> (cdr '(a b c))
(B C)
> (cons 1 (cons 2 (cons 3 ())))
(1 2 3)
> (define '((fact (lambda (n) (cond ((zerop n) 1) (t (times n (fact (sub1 n)))))))))
(FACT)
> (fact 10)
3628800
> (define '((gen (lambda (n) (function (lambda (m) (setq n (plus n m))))))))
(GEN)
> (prog (x) (setq x (gen 100)) (print (x 10)) (print (x 90)) (print (x 300)))
110
200
500
NIL
> (compile '(fact))
NIL
> (fact 10)
3628800
For running locally:
% wat2wasm ichigo.wat -o ichigo.wasm # Convert WASM text format to binary
% http-server # Run HTTP server locally because file:https:// isn't supported
Ichigo Lisp supports most of features written in
LISP 1.5 Programmer's Manual
except array and floating point number.
COMPILE generates WebAssembly binaries.
Some functions behave differently from LISP 1.5.
For example COND
returns NIL when no conditions are satisfied while LISP 1.5
returns an error in that case.
SUBRs are functions written in WebAssembly.
You can check the latest status by evaluating (symbols-with 'subr)
.
- ADD1
- ADVANCE
- APPEND
- APPLY
- ATOM
- ATTRIB
- CAR
- CDR
- CLEARBUFF
- COMMON
- COMPILE
- CONS
- COPY
- COUNT
- DASH
- DIFFERENCE
- DIGIT
- DIVIDE
- DUMP
- EFFACE
- ENDREAD
- EQ
- EQUAL
- ERROR
- ERRORSET
- EVAL
- EVLIS
- EXPT
- FIXP
- FLOATP
- GENSYM
- GET
- GREATERP
- INTERN
- LEFTSHIFT
- LENGTH
- LESSP
- LITER
- MAP
- MAPCON
- MAPLIST
- MEMBER
- MINUS
- MINUSP
- MKNAM
- NCONC
- NOT
- NULL
- NUMBERP
- NUMOB
- ONEP
- OPCHAR
- PACK
- PAIR
- PRIN1
- PROG2
- PROP
- PUNCH
- QUOTIENT
- READ
- RECIP
- RECLAIM
- REMAINDER
- REMOB
- REMPROP
- RETURN
- REVERSE
- RPLACA
- RPLACD
- SASSOC
- SEARCH
- SET
- SPEAK
- SPECIAL
- STARTREAD
- SUB1
- SUBLIS
- SUBST
- TERPRI
- UNCOMMON
- UNCOUNT
- UNPACK
- UNSPECIAL
- ZEROP
- - (same as
DIFFERENCE
) - / (same as
QUOTIENT
) - 1+ (same as
ADD1
) - 1- (same as
SUB1
) - < (same as
LESSP
) - > (same as
GREATERP
) - PUTPROP
- ARRAY
- CP1
- ERROR1
- EXCISE
- LAP
- LOAD
- PAUSE
- PLB
- READLAP
- TEMPUS-FUGIT
FSUBRs are functions, that don't evaluate arguments, written in WebAssembly.
You can check the latest status by evaluating (symbols-with 'fsubr)
.
- AND
- COND
- FUNCTION
- GO
- LABEL
- LIST
- LOGAND
- LOGOR
- LOGXOR
- MAX
- MIN
- OR
- PLUS
- PROG
- QUOTE
- SETQ
- TIMES
- * (same as
TIMES
) - + (same as
PLUS
) - IF
EXPRs are functions written in Lisp.
You can check the latest status by evaluating (symbols-with 'expr)
.
- CSET
- DEFINE
- DEFLIST
- FLAG
- PRINTPROP
- PUNCHDEF
- REMFLAG
- TRACE
- TRACESET
- UNTRACE
- UNTRACESET
- REMOVE-IF-NOT
- SYMBOLS-WITHs
- OPDEFINE
- PUNCHLAP
FEXPRs are functions, that don't evaluate arguments, written in Lisp.
You can check the latest status by evaluating (symbols-with 'fexpr)
.
- CONC
- CSETQ
- SELECT
- DE
- DEFUN
- DF