map

Function map 

Source
pub fn map() -> Term
Expand description

Applied to a function and a lambda-encoded option it applies the function to the contents of the option, returning the empty option if the option does not contain a value.

MAP ≡ λfm.m NONE (λx.SOME (f x)) ≡ λ λ 1 NONE (λ SOME (3 1))

§Example

use lambda_calculus::data::option::{map, none};
use lambda_calculus::data::num::church::succ;
use lambda_calculus::*;

let some_one: Term = Some(1).into_church();

assert_eq!(beta(app!(map(), succ(), some_one), NOR, 0), Some(2).into_church());
assert_eq!(beta(app!(map(), succ(), none()), NOR, 0), none());