A minimalist Lisp interpreter is available in MOROS to extend the capabilities of the Shell.
MOROS Lisp is a Lisp-1 dialect inspired by Scheme and Clojure.
It started from Risp and was extended to include the seven primitive operators and the two special forms of John McCarthy's paper "Recursive Functions of Symbolic Expressions and Their Computation by Machine" (1960) and "The Roots of Lisp" (2002) by Paul Graham.
In version 0.2.0 the whole implementation was refactored and the parser was rewritten to use Nom. This allowed the addition of strings to the language and reading from the filesystem.
quote
(with the'
syntax)atom
(aliased toatom?
)eq
(aliased toeq?
)car
(aliased tofirst
)cdr
(aliased torest
)cons
cond
label
(aliased todef
)lambda
(aliased tofn
)
-
defun
(aliased todefn
) -
mapcar
(aliased tomap
) -
print
-
read
-
read-bytes
-
bytes
-
str
-
cat
-
join
-
lines
-
parse
-
type
-
system
-
Arithmetic operations:
+
,-
,*
,/
,%
,^
-
Trigonometric functions:
acos
,asin
,atan
,cos
,sin
,tan
-
Comparisons:
>
,<
,>=
,<=
,=
-
Boolean operations:
and
,or
The interpreter can be invoked from the shell:
> lisp
MOROS Lisp v0.1.0
> (+ 1 2)
3
> (quit)
And it can execute a file. For example a file located in /tmp/fibonacci.lsp
with the following content:
(defn fib (n)
(cond
((< n 2) n)
(true (+ (fib (- n 1)) (fib (- n 2))))))
(println (fib 10))
Would produce the following output:
> lisp /tmp/fibonacci.lsp
55