adding test
This commit is contained in:
parent
55d84eec95
commit
dfbb278e4b
20
runtime.js
20
runtime.js
|
@ -43,6 +43,24 @@ var Primitives = (function() {
|
|||
var secondArg = MACHINE.env[MACHINE.env.length-2];
|
||||
return firstArg < secondArg;
|
||||
},
|
||||
|
||||
'>': function(arity, returnLabel) {
|
||||
var firstArg = MACHINE.env[MACHINE.env.length-1];
|
||||
var secondArg = MACHINE.env[MACHINE.env.length-2];
|
||||
return firstArg > secondArg;
|
||||
},
|
||||
|
||||
'<=': function(arity, returnLabel) {
|
||||
var firstArg = MACHINE.env[MACHINE.env.length-1];
|
||||
var secondArg = MACHINE.env[MACHINE.env.length-2];
|
||||
return firstArg <= secondArg;
|
||||
},
|
||||
|
||||
'>=': function(arity, returnLabel) {
|
||||
var firstArg = MACHINE.env[MACHINE.env.length-1];
|
||||
var secondArg = MACHINE.env[MACHINE.env.length-2];
|
||||
return firstArg >= secondArg;
|
||||
},
|
||||
|
||||
'+': function(arity, returnLabel) {
|
||||
var firstArg = MACHINE.env[MACHINE.env.length-1];
|
||||
|
@ -100,10 +118,12 @@ var Primitives = (function() {
|
|||
var firstArg = MACHINE.env[MACHINE.env.length-1];
|
||||
return firstArg === NULL;
|
||||
},
|
||||
|
||||
'add1': function(arity, returnLabel) {
|
||||
var firstArg = MACHINE.env[MACHINE.env.length-1];
|
||||
return firstArg + 1;
|
||||
},
|
||||
|
||||
'sub1': function(arity, returnLabel) {
|
||||
var firstArg = MACHINE.env[MACHINE.env.length-1];
|
||||
return firstArg - 1;
|
||||
|
|
|
@ -63,4 +63,13 @@
|
|||
(displayln (fib 5))
|
||||
(displayln (fib 6)))
|
||||
"2\n3\n5\n8\n")
|
||||
|
||||
|
||||
|
||||
(test '(begin (define (tak x y z)
|
||||
(if (>= y x)
|
||||
z
|
||||
(tak (tak (- x 1) y z)
|
||||
(tak (- y 1) z x)
|
||||
(tak (- z 1) x y))))
|
||||
(displayln (tak 18 12 6)))
|
||||
"7\n")
|
Loading…
Reference in New Issue
Block a user