pub fn index() -> Term
Expand description
Applied to a Church-encoded number i
and a pair-encoded list it returns the i
-th
(zero-indexed) element of the list.
INDEX ≡ λil.HEAD (i TAIL l) ≡ λ λ HEAD (2 TAIL 1)
Example
use lambda_calculus::data::list::pair::index;
use lambda_calculus::*;
let list = vec![1.into_church(), 2.into_church(), 3.into_church()];
assert_eq!(
beta(app!(index(), 0.into_church(), list.into_pair_list()), NOR, 0),
1.into_church()
);