A Lisp-like programming language written in Rust.
Lispen follows the same syntax as some Lisp dialects:
(println "Hello World")The example above is a list, which, by default, is interpreted as a function call if the first argument is an identifier.
To define a variable in Lispen, you use the set keyword.
(set x 10)This will bind the value 10 to the variable x in the current scope.
numstrboollistfnnil
All numbers in Lispen have the same type, num, and it supports both integers and floats.
Note: inside the interpreter this type is represented by a
f64.
Lispen, like other Lisp dialects, uses the Polish notation to represent arithmetic.
This is the syntax:
(operator operand1 operand2)Example of a sum:
(+ 1 2)Like explained above, lists can represent function calls, if the first argument is an identifier.
But you can also make the list be interpreted as a literal list, even if the first argument is an identifier.
Use the quote ' character before the list:
'(println 10)In this case, it'll be evaluated to a list with two elements, a function and a number.
There are two ways of defining functions in Lispen: using the defn and the fn keywords.
Every function creates a new scope inside it.
defn defines a function and also binds it to a name.
(defn f(x) (+ x 1))fn only defines a function.
(fn(x) (+ x 1))To assign it to a name, you can use the set keyword.
(set x (fn(x) (+ x 1)))