, . "unabstractable", .
, . , , . , , . , , , enum.
, . Term
, , .
, , - .
, , ,
, . , , , :
To read one term, given a mutable reference to a variable stack (which begins empty):
If the next character is an opening parenthesis:
Consume it.
Read a term.
Read a term.
Make sure the next character is a closing parenthesis, and consume it.
Return an application of the two terms.
If the next character is a lambda:
Consume it.
Make sure the next character is a variable, then consume it.
Make sure the next character is a dot, and consume it.
Push the variable to the variable stack.
Read a term.
Pop the variable off of the stack.
Return an abstraction of the term.
If the next character is a variable:
Consume it.
Search the variable stack find the first index of the variable from the top.
Return a variable term with this index.
, -, (a b c)
((a b) c)
. λx.λy.λz.((x z) (y z))
, λx.λy.λz.x z (y z)
.
( )
, , , - , , , . , , . , , , , , , , , , , . , . , , 1 .
, Term
:
fn substitute(&mut self, variable_number: usize, other: &Term);
, , :
λn.λf.λx.(f ((n f) x))
→ Abs(Abs(Abs(App(Var(1),App(App(Var(2),Var(1)),Var(0))))))
( , , , , )
, . Term
, , Abs
, , 0. , App
, , . , - , , , , .
, -. , , , -.
, , , . enum, , .