MissingLisp is a minimalist Lisp interpreter embedded in Ruby. It allows you to write and evaluate Lisp expressions with Ruby's variable names.
gem install missinglisp$ irb
irb(main):001> require 'missinglisp'
=> true
irb(main):002> Lquote_hello_world_J
=> [:hello, :world]
irb(main):003> Ladd_1_2_3J
=> 6Other examples can be found in the examples directory.
MissingLisp implements a subset of Lisp.
- Uses
Linstead of(to open expressions - Uses
Jinstead of)to close expressions- Note:
Lfoo_barJis tokenized asL,foobarJ. If you want to useJas closing parentheses, you must use_to separate the token:Lfoo_bar_J
- Note:
- Symbols are written as normal identifiers (e.g.,
add,define,lambda) - Numbers are written as normal numbers
- Whitespace is ignored. Uses
_instead of spaces
Lif_test_then_elseJ- Conditional expressionLquote_expressionJ- Returns the expression without evaluating itLdefine_symbol_expressionJ- Defines a symbol in the current environmentLlambda_Lparameters_J_bodyJ- Creates a function
MissingLisp provides several built-in functions:
car- Returns the first element of a listcdr- Returns all but the first element of a listcons- Constructs a new list by prepending an elementlist- Creates a list from its arguments
add- Adds numberssub- Subtracts numbersmult- Multiplies numbersdiv- Divides numbers
eq- Tests equalitylt- Less thanleq- Less than or equalgt- Greater thangeq- Greater than or equal
p- Prints values (for debugging)nil- An empty list
MIT