Expand description
A lambda term that is either a variable with a De Bruijn index, an abstraction over a term or
an applicaction of one term to another.
Returns a variable’s De Bruijn index, consuming it in the process.
use lambda_calculus::*;
assert_eq!(Var(1).unvar(), Ok(1));
Returns a TermError if self is not a Variable.
Returns a reference to a variable’s De Bruijn index.
use lambda_calculus::*;
assert_eq!(Var(1).unvar_ref(), Ok(&1));
Returns a TermError if self is not a Variable.
Returns a mutable reference to a variable’s De Bruijn index.
use lambda_calculus::*;
assert_eq!(Var(1).unvar_mut(), Ok(&mut 1));
Returns a TermError if self is not a Variable.
Returns an abstraction’s underlying term, consuming it in the process.
use lambda_calculus::*;
assert_eq!(abs(Var(1)).unabs(), Ok(Var(1)));
Returns a TermError if self is not an Abstraction.
Returns a reference to an abstraction’s underlying term.
use lambda_calculus::*;
assert_eq!(abs(Var(1)).unabs_ref(), Ok(&Var(1)));
Returns a TermError if self is not an Abstraction.
Returns a mutable reference to an abstraction’s underlying term.
use lambda_calculus::*;
assert_eq!(abs(Var(1)).unabs_mut(), Ok(&mut Var(1)));
Returns a TermError if self is not an Abstraction.
Returns a pair containing an application’s underlying terms, consuming it in the process.
use lambda_calculus::*;
assert_eq!(app(Var(1), Var(2)).unapp(), Ok((Var(1), Var(2))));
Returns a TermError if self is not an Application.
Returns a pair containing references to an application’s underlying terms.
use lambda_calculus::*;
assert_eq!(app(Var(1), Var(2)).unapp_ref(), Ok((&Var(1), &Var(2))));
Returns a TermError if self is not an Application.
Returns a pair containing mutable references to an application’s underlying terms.
use lambda_calculus::*;
assert_eq!(app(Var(1), Var(2)).unapp_mut(), Ok((&mut Var(1), &mut Var(2))));
Returns a TermError if self is not an Application.
Returns the left-hand side term of an application. Consumes self.
use lambda_calculus::*;
assert_eq!(app(Var(1), Var(2)).lhs(), Ok(Var(1)));
Returns a TermError if self is not an Application.
Returns a reference to the left-hand side term of an application.
use lambda_calculus::*;
assert_eq!(app(Var(1), Var(2)).lhs_ref(), Ok(&Var(1)));
Returns a TermError if self is not an Application.
Returns a mutable reference to the left-hand side term of an application.
use lambda_calculus::*;
assert_eq!(app(Var(1), Var(2)).lhs_mut(), Ok(&mut Var(1)));
Returns the right-hand side term of an application. Consumes self.
use lambda_calculus::*;
assert_eq!(app(Var(1), Var(2)).rhs(), Ok(Var(2)));
Returns a TermError if self is not an Application.
Returns a reference to the right-hand side term of an application.
use lambda_calculus::*;
assert_eq!(app(Var(1), Var(2)).rhs_ref(), Ok(&Var(2)));
Returns a TermError if self is not an Application.
Returns a mutable reference to the right-hand side term of an application.
use lambda_calculus::*;
assert_eq!(app(Var(1), Var(2)).rhs_mut(), Ok(&mut Var(2)));
Returns a TermError if self is not an Application.
Returns true if self is a
supercombinator.
use lambda_calculus::*;
let term1 = abs(app(Var(1), abs(Var(1))));
let term2 = app(abs(Var(2)), abs(Var(1)));
assert_eq!(term1.is_supercombinator(), true);
assert_eq!(term2.is_supercombinator(), false);
Applies a Term to self via substitution and variable update.
use lambda_calculus::*;
let mut term1 = parse(&"λλ42(λ13)", DeBruijn).unwrap();
let term2 = parse(&"λ51", DeBruijn).unwrap();
let result = parse(&"λ3(λ61)(λ1(λ71))", DeBruijn).unwrap();
term1.apply(&term2);
assert_eq!(term1, result);
Returns a TermError if self is not an Abstraction.
Performs β-reduction on a Term with the specified evaluation Order and an optional limit
on the number of reductions (0 means no limit) and returns the number of performed
reductions.
use lambda_calculus::*;
let mut expression = parse(&"(λa.λb.λc.b (a b c)) (λa.λb.b)", Classic).unwrap();
let reduced = parse(&"λa.λb.a b", Classic).unwrap();
expression.reduce(NOR, 0);
assert_eq!(expression, reduced);
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used
by ==. Read more
This method tests for !=.
impl<T> Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl<T, U> Into<U> for T where
U: From<T>,
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.