This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cx = new env; | |
console.log(leval(['set','a',42],cx)); | |
console.log(leval('a',cx)); | |
console.log(leval(['eq',42,'a'],cx)); | |
console.log(leval(['quote',[1,2]],cx)); | |
console.log(leval(['fst',['quote',[1,2]]],cx)); | |
console.log(leval(['rst',['quote',[1,2]]],cx)); | |
console.log(leval(['cons',1,['quote',[2,3]]],cx)); | |
console.log(leval(['cond',['eq',1,2],42,43],cx)); | |
console.log(leval(['atom',['quote',[1,2]]],cx)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def pop; $stack.pop || raise(StackUnderflow); end | |
def push(expression); $stack << expression; end | |
def unary; -> { push(yield pop) }; end | |
def binary; -> { push(yield pop, pop) }; end | |
def unary_boolean; -> { push(if yield pop then 1 else 0 end) }; end | |
def binary_boolean; -> { push(if yield pop, pop then 1 else 0 end) }; end | |
def swap; $stack[-2,2] = $stack[-2,2].reverse; end | |
$stack = [] |