Created
May 24, 2019 20:27
-
-
Save arjunguha/fecab7576230392cc61d815e717c189a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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