Created
September 19, 2011 16:56
-
-
Save Newky/1226949 to your computer and use it in GitHub Desktop.
Bit of prolog like magic with JavaScript
This file contains 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
/*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