Created
March 8, 2012 00:54
-
-
Save mattneary/1997661 to your computer and use it in GitHub Desktop.
Esoteric language with 2 vars and only recursive function calls
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
var parseLambda = function(string) { | |
var replacements = [ | |
[/\^/g, "++x;"], | |
[/_/g, "--x;"], | |
[/\~/g, "++v;"], | |
[/\./g, "--v;"], | |
[/\$/g, "x"], | |
[/\#/g, "v"], | |
[/@/g, "return "], | |
[/!\(([^)]+)\)/g, "arguments.callee($1)"], | |
[/\{/g, "(function(x,v) {x=x||0,v=v||0;"], | |
[/\}/g, ";})"] | |
]; | |
for( var k in replacements ) | |
string = string.replace(replacements[k][0], replacements[k][1]); | |
return eval("var x = v = 0;"+string); | |
} | |
parseLambda("^^^^^{@$?{@ # ? $+!($,{_@$}(#)) : {@$}()}($,!({_@$}($))):{^@$}()}($)"); | |
//Syntax... | |
//@: Return | |
//^: Increment Parameter $ | |
//_: Decrement Parameter $ | |
//~: Increment Parameter # | |
//.: Decrement Parameter # | |
//$: Parameter Value 1 | |
//#: Parameter Value 2 | |
//!: Current function | |
//+: Addition, for efficiency | |
//: and ?: Ternary operators | |
//{...}(...): Function | |
//Nothing else at all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment