Function lambda_calculus::booleans::if_else [] [src]

pub fn if_else() -> Term

Applied to a Church encoded predicate and two terms it returns the first one if the predicate is true or the second one if the predicate is false.

IF_ELSE := λpab.p a b = λ λ λ 3 2 1

Examples

use lambda_calculus::booleans::{if_else, tru, fls};
use lambda_calculus::arithmetic::{zero, one};
use lambda_calculus::reduction::beta_full;

assert_eq!(beta_full(if_else().app(tru()).app(one()).app(zero())), one());
assert_eq!(beta_full(if_else().app(fls()).app(one()).app(zero())), zero());