Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,33 @@
var proggie = '3 4 2 * 1 5 - 2 3 ^ ^ / +'
class RPN(arr=[]) {
method binop(op) {
var x = arr.pop
var y = arr.pop
arr << y.(op)(x)
}
method run(p) {
p.each_word { |w|
say "#{w} (#{arr})"
given (w) {
when (/\d/) {
arr << Num(w)
}
when (<+ - * />) {
self.binop(w)
}
when ('^') {
self.binop('**')
}
default {
die "#{w} is bogus"
}
}
}
say arr[0]
}
}
RPN.new.run(proggie)