eloquent higher order control flow

by Rich Costello

JavaScript

function unless(test, then) {
  if (!test) then();
}
function repeat(times, body) {
  for (var i = 0; i < times; i++) body(i);
}
repeat(8, function(n) {
  unless(n % 2, function() {
    console.log(n, "is even");
  });
});