Function lamcal::app[][src]

pub fn app(lhs: Term, rhs: Term) -> Term

Constructs a function application with the lhs term to be applied to the rhs term.

This is a convenience function for constructing a Term of variant Term::App in a readable form with minimal keystrokes. It takes two Terms as its input and returns a Term::App with the first Term to be applied to the second Term.

This function combined with the functions var and lam let us construct any Term in the untyped lambda calculus.

Examples

let application = app(lam("x", var("x")), var("y"));

assert_eq!(
    application,
    Term::App(
        Box::new(Term::Lam(
            VarName("x".to_string()),
            Box::new(Term::Var(VarName("x".to_string())))
        )),
        Box::new(Term::Var(VarName("y".to_string())))
    )
);