Skip to content

Instantly share code, notes, and snippets.

@Newky
Created September 19, 2011 16:56
Show Gist options
  • Save Newky/1226949 to your computer and use it in GitHub Desktop.
Save Newky/1226949 to your computer and use it in GitHub Desktop.
Bit of prolog like magic with JavaScript
/*Prolog Num succ and prev defined in some wierd ass JS */
var num= (function(num) {
num = num || 0;
var x = num;
return {
s: function() {
x+=1;
return x;
},
p: function() {
x-=1;
return x;
}
};
})();
var succ = num.s;
var prev = num.p;
console.log(succ(prev()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment