Function lambda_calculus::data::list::scott::cons

source ·
pub fn cons() -> Term
Expand description

Applied to two terms it returns them contained in a Scott-encoded list.

CONS ≡ λaxnc.c a x ≡ λ λ λ λ 1 4 3

Example

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

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

let list_into = vec![1, 2, 3].into_scott();

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