Project

minilisp

0.0
No commit activity in last 3 years
No release in over 3 years
Lisp in 32 lines of Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.3
>= 0
 Project Readme

Minilisp

Minilisp is a micro Lisp interpreter implemented in Ruby so you can do a lisp sorcery in hacking your ruby projects. :p

Installation

Add this line to your application's Gemfile:

gem 'minilisp'

And then execute:

$ bundle

Or install it yourself as:

$ gem install minilisp

Usage

The LISP interpreter is just a Ruby class that evals expressions in Ruby data structures, like so:

l = Minilisp::Interpreter.new

l.eval [:label, :a, 42]

l.eval :a
#=> 42

l.eval [:eq, 42, :a]
#=> true

l.eval [:quote, [1, 2]]
#=> [1, 2]

l.eval [:car, [:quote, [1, 2]]]
#=> 1

l.eval [:cdr, [:quote, [1, 2]]]
#=> [2]

l.eval [:cons, 1, [:quote, [2,3]]]
#=> [1, 2, 3]

l.eval [:if, [:eq, 1, 2], 42, 43]
#=> 43

l.eval [:atom, [:quote, [1,2]]]
#=> false

l.eval [:label, :second, [:quote, [:lambda, [:x],   [:car, [:cdr, :x]]]]]

l.eval [:second, [:quote, [1, 2, 3]]]
#=> 2

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Acknowledgement

License

MIT.