Skip to content

Instantly share code, notes, and snippets.

@mattneary
Created March 8, 2012 00:54
Show Gist options
  • Save mattneary/1997661 to your computer and use it in GitHub Desktop.
Save mattneary/1997661 to your computer and use it in GitHub Desktop.
Esoteric language with 2 vars and only recursive function calls
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