Skip to content

Instantly share code, notes, and snippets.

@arjunguha
Created May 24, 2019 20:27
Show Gist options
  • Save arjunguha/fecab7576230392cc61d815e717c189a to your computer and use it in GitHub Desktop.
Save arjunguha/fecab7576230392cc61d815e717c189a to your computer and use it in GitHub Desktop.
function choose(args) {
return shift(function(k) {
let results = [ ];
for (let i = 0; i < args.length; i++) {
results = results.concat(k(args[i]));
}
return results;
});
}
function fail() {
return shift(function(k) {
return [];
});
}
function driver(body) {
return reset(function() {
return [body()];
});
}
function F() {
return choose([1,2,3]);
}
results = driver(function() {
let x = F();
let y = F();
if ((x + y) % 2 !== 0) {
fail();
}
return x + y;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment