Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function generate_math_operator(op) {
return function(args) {
var res = args[0], i, tmp;
for (i=1; i<args.length; i++) {
tmp = predicates.is_object(op) ? ast_to_js(op) : op;
res += " " + tmp + " " + args[i];
}
return res;
};
}
var add = generate_math_operator("+");
var sub = generate_math_operator("-");
var mul = generate_math_operator("*");
var div = generate_math_operator("/");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.