Function lambda_calculus::data::option::map_or
source · pub fn map_or() -> Term
Expand description
Applied to two arguments and a lambda-encoded option it returns the second argument applied to the contents of the option if it contains a value or the first argument if it doesn’t.
MAP_OR ≡ λdfm.m d f ≡ λ λ λ 1 3 2
Example
use lambda_calculus::data::option::{map_or, none};
use lambda_calculus::data::num::church::succ;
use lambda_calculus::*;
let some_one: Term = Some(1).into_church();
assert_eq!(beta(app!(map_or(), 0.into_church(), succ(), some_one), NOR, 0), 2.into_church());
assert_eq!(beta(app!(map_or(), 0.into_church(), succ(), none()), NOR, 0), 0.into_church());