Call
Call is an implementation of Lambda Calculus using only the symbols `(` and `)`
Syntax
Code in call is a balanced sequence of round brackets (
)
all other characters will be ignored.
The contents of the first bracket will be parsed a lambda expression.
All successive brackets are function arguments, they will be recursively parsed as sub-expressions. (First element as lambda-function, all successive elements as arguments)
Within Lambda expressions, brackets containing multiple elements are used to group elements, nested brackets containing an empty bracket are used to encode the positions of the arguments of the lambda expression, with the argument index being encoded by the nesting depth (() -> 0
(()) -> 1
)
For example:
((())(()(())((())))) ( (()(())) () ( ((())()) ) )
will be parsed as
[Labc.b(a b c)] ( [Lab.ab] [La.a] [Lab.ba] )
Some lambda expressions with unused arguments (e.g. x->y->x
) cannot directly be represented, they can be encoded by adding additional arguments and passing functions that will reorganize the body of the expression in the required way.
For instance x->y->x
can be encoded as (a->b->c->a c b) (x->y->y)
giving the expression (()((()))(()))(((())))
Examples
Church literals for 0 to 3:
0: ((()))
1: (()(()))
2: (()(()(())))
3: (()(()(()(()))))
Successor function (n->g->x->g (n g x)
):
((())(()(())((()))))
Addition (m->n->f->x-> m f (n f x)
):
(()((()))((())((()))(((())))))
Computational class
Call implements lambda calculus which is Turing complete