Skip to content

Instantly share code, notes, and snippets.

@topher6345
Created March 10, 2016 06:00
Show Gist options
  • Save topher6345/642f372cdedcd967ceda to your computer and use it in GitHub Desktop.
Save topher6345/642f372cdedcd967ceda to your computer and use it in GitHub Desktop.
A basic 4 operator LISP implemented in ruby.
module LISPO
module ArrayCallable
refine Array do
def call
inject &shift
end
end
end
class Parser
def self.call(string)
string.gsub! '(', '[:'
string.gsub! ' ', ', '
string.gsub! ')', '].call'
end
end
module VM
using ArrayCallable
def self.call(string)
module_eval Parser.call(string)
end
end
end
puts LISPO::VM.call <<-LISP
(+ 1 2 (* 2 9) 4 6 7)
LISP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment