cons

Function cons 

Source
pub fn cons() -> Term
Expand description

Applied to two terms it returns them contained in a pair-encoded list; equivalent to pair::pair.

CONS ≡ λxyz.z x y ≡ λ λ λ 1 3 2 ≡ PAIR

§Example

use lambda_calculus::data::list::pair::{nil, cons};
use lambda_calculus::*;

let list_consed =
    app!(
        cons(),
        1.into_church(),
        app!(
            cons(),
            2.into_church(),
            app!(
                cons(),
                3.into_church(),
                nil()
            )
        )
    );

let list_from_vec = vec![1.into_church(), 2.into_church(), 3.into_church()].into_pair_list();

assert_eq!(beta(list_consed, NOR, 0), list_from_vec);