putting the operate function in operation.js, to facilitate access from browser code

This commit is contained in:
cloudhead
2010-03-23 01:19:12 -04:00
parent f76f6984a9
commit 374702c926
2 changed files with 8 additions and 10 deletions

View File

@@ -1,11 +1 @@
var tree = exports;
tree.operate = function (op, a, b) {
switch (op) {
case '+': return a + b;
case '-': return a - b;
case '*': return a * b;
case '/': return a / b;
}
};

View File

@@ -20,3 +20,11 @@ tree.Operation.prototype.eval = function (env) {
return a.operate(this.op, b);
};
tree.operate = function (op, a, b) {
switch (op) {
case '+': return a + b;
case '-': return a - b;
case '*': return a * b;
case '/': return a / b;
}
};