Skip to content
Snippets Groups Projects
Commit 45a67ca7 authored by Paul IANNETTA's avatar Paul IANNETTA Committed by Thomas Wood
Browse files

removed unwanted auto-generated javascript test files

parent a1c787da
No related branches found
No related tags found
No related merge requests found
var eval_ = function (expr) {
return (function () {
switch (expr.type) {
case "Const": var n = expr.value;
return n;
case "Add": var ls = expr.left, rs = expr.right;
return add(eval_(ls), eval_(rs));
case "Sub": var ls = expr.left, rs = expr.right;
return sub(eval_(ls), eval_(rs));
case "Mul": var ls = expr.left, rs = expr.right;
return mul(eval_(ls), eval_(rs));
case "Div": var ls = expr.left, rs = expr.right;
return div(eval_(ls), eval_(rs));
}
})();
};
var print_expr = function (expr) {
return (function () {
switch (expr.type) {
case "Const": var n = expr.value;
return to_string(n);
case "Add": var ls = expr.left, rs = expr.right;
return add(add(add(add("(", print_expr(ls)), ")"), " + "), print_expr(rs));
case "Sub": var ls = expr.left, rs = expr.right;
return add(add(add(add("(", print_expr(ls)), ")"), " - "), print_expr(rs));
case "Mul": var ls = expr.left, rs = expr.right;
return add(add(add(add("(", print_expr(ls)), ")"), " * "), print_expr(rs));
case "Div": var ls = expr.left, rs = expr.right;
return add(add(add(add("(", print_expr(ls)), ")"), " / "), print_expr(rs));
}
})();
};
var f = (function () {
var source = parse("((1972 / 29) / 2) + 8");
return print(add(add(print_expr(source), " = "), to_string(eval_(source))));
})();
(function () {
var abr = 1;
var bli = 4;
return (function () {
if (true) {
return abr;
} else {
return bli;
}
})();
})()
var app = function (x) {
return x;
};
var app2 = function (x) {
return x;
};
var affiche = function (x) {
return (function () {
switch (x.type) {
case "As":
return "As";
case "Petite": var n = x.petite;
return "Petite";
}
})();
};
var pet = {type: "Petite", petite: 5};
var cinq = 5;
var incr = function (i) {
return add(i, 1);
};
var head = function (d, l) {
return (function () {
switch (l.type) {
case "Nil":
return d;
case "Cons": var x = l.hd, xs = l.tl;
return x;
}
})();
};
var tail = function (d, l) {
return (function () {
switch (l.type) {
case "Nil":
return d;
case "Cons": var x = l.hd, xs = l.tl;
return xs;
}
})();
};
var init = function (l) {
return (function () {
switch (l.type) {
case "Nil":
return {type: "Nil"};
case "Cons": var x = l.hd, xs = l.tl;
return xs;
}
})();
};
var last = function (l) {
return (function () {
switch (l.type) {
case "Nil":
return {type: "Nil"};
case "Cons": var x = l.hd, xs = l.tl;
return (function () {
switch (xs.type) {
case "Nil":
return x;
default:
return last(xs);
}
})();
}
})();
};
var fold_left = function (f, acc, l) {
return (function () {
switch (l.type) {
case "Nil":
return acc;
case "Cons": var x = l.hd, xs = l.tl;
return fold_left(f, f(acc, x), xs);
}
})();
};
var fold_right = function (f, l, acc) {
return (function () {
switch (l.type) {
case "Nil":
return acc;
case "Cons": var x = l.hd, xs = l.tl;
return f(fold_right(f, xs, acc), x);
}
})();
};
var rev_map = function (f, l) {
return fold_left(function (acc, x) {
return {type: "Cons", hd: f(x), tl: acc};
}, {type: "Nil"}, l);
};
var map = function (f, l) {
return fold_right(function (acc, x) {
return {type: "Cons", hd: f(x), tl: acc};
}, l, {type: "Nil"});
};
var length = function (l) {
return fold_left(function (acc, x) {
return incr(acc);
}, 0, l);
};
var range = function (i, j, acc) {
return (function () {
if (le(i, j)) {
return range(incr(i), j, {type: "Cons", hd: i, tl: acc});
} else {
return acc;
}
})();
};
var list0 = {type: "Nil"};
var list1 = range(0, 1, {type: "Nil"});
var list2 = range(1, 5, {type: "Nil"});
var sqr = function (x) {
return mul(x, x);
};
length(list0)
length(list1)
length(list2)
map(sqr, list0)
map(sqr, list1)
map(sqr, list2)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment