sum = function (a) { var s = 0; from_to(0, a.length-1, function (i) { s = s + a[i]; }); return s; } sum([1,2,3]);
Output