7 stable releases
1.0.6 | Jun 29, 2022 |
---|---|
1.0.5 | Jun 6, 2022 |
1.0.4 | Apr 10, 2022 |
1.0.1 | Apr 9, 2022 |
1.0.0 | Apr 5, 2022 |
#476 in Programming languages
50KB
1K
SLoC
Lithia
lisp implemented in rust
Name
Name comes from another name for Lithium Oxide
Functions
quote
Returns whatever its given, used for when you don't want to evaluate somethingexit
Exit lisp interpreter, number may be provided for exit code=
,set
Sets a variabledef
Define a globaldefunc
Define a global functioneval
Evaluates the given object and what it returnsprint
Display an objectread
Reads a line into objectsinclude
Reads a file and evaluates it, returning the last objectwhile
While first argument isn't nil, evaluates the restread
Prompts for input and converts it to objectsfunc
Creates a function- Use:
(func (arg1 arg2) (body) (body) return_value)
car
,first
Gets the first element in a dot-paircdr
,next
Gets the second element in a dot-pair
Math functions
+
,add
-
,sub
*
,mul
/
,div
%
,mod
==
,eq
!=
,ne
lib.rs
:
This crate provides a LISP implementation for embedding within rust programs
With support for providing rust functions as LISP functions within the environment
Usage
This crate is on crates.io and can be
used by adding lithia
to your dependencies in your project's Cargo.toml
.
[dependencies]
lithia = "*"
Example: simple REPL
let code = "(while t (print (eval (read))))".to_string()
let mut globals = HashMap::new();
let ret = Lisp::new(&mut globals)
.add_stdenv().unwrap()
.eval(&code);
Dependencies
~2–3MB
~54K SLoC