Translator
Lambda calculus:
Klambda:
Explanation
Klambda is a compact language for representing untyped higher-order functions.
It only differs in two ways from the standard lambda calculus language:
-
Function application is represented using the + character in prefix notation.
This eliminates ambiguity and the need for parentheses (which are not allowed in klambda) and makes klambda easy to programmatically parse.
-
Variables are not named. Lambda abstractions are introduced with just "." instead of "\x.", and the letter used when a variable occurs in an expression is determined by the occurrence's distance (structurally) from the lambda to which it is bound: "a" refers to the the closest enclosing lambda abstraction, "b" to the second-closest enclosing lambda abstraction, and so on. For example, "..a" represents \x.\y.y and "..b" represents \x.\y.x. In ".+a.+ab", the "b" refers to the same variable as the first "a", but the second "a" refers to another variable.
Issues of "alpha-equivalence" (variable renaming) and "capture-avoiding" (preventing variable name collisions during substitution) don't exist in klambda;
identical structures always have identical representations regardless of where they appear, and you can safely copy/move subexpressions around without messing things up.
I think these properties (conciseness and context-insensitivity/representation uniqueness) make klambda appealing, even though it's not very human-readable.