1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! [Lambda-encoded `n`-tuple](https://www.mathstat.dal.ca/~selinger/papers/lambdanotes.pdf)
//!
//! This module contains the `tuple` and `pi` macros.
/// A macro for creating lambda-encoded tuples.
///
/// # Example
/// ```
/// # #[macro_use] extern crate lambda_calculus;
/// # fn main() {
/// use lambda_calculus::term::*;
/// use lambda_calculus::*;
///
/// assert_eq!(
/// tuple!(1.into_church(), 2.into_church()),
/// abs(app!(Var(1), 1.into_church(), 2.into_church()))
/// );
///
/// assert_eq!(
/// tuple!(1.into_church(), 2.into_church(), 3.into_church()),
/// abs(app!(Var(1), 1.into_church(), 2.into_church(), 3.into_church()))
/// );
/// # }
/// ```
/// A macro for obtaining a projection function (`π`) providing the `i`-th (one-indexed) element of
/// a lambda-encoded `n`-tuple.
///
/// # Example
/// ```
/// # #[macro_use] extern crate lambda_calculus;
/// # fn main() {
/// use lambda_calculus::term::*;
/// use lambda_calculus::*;
///
/// let t2 = || tuple!(1.into_church(), 2.into_church());
///
/// assert_eq!(beta(app(pi!(1, 2), t2()), NOR, 0), 1.into_church());
/// assert_eq!(beta(app(pi!(2, 2), t2()), NOR, 0), 2.into_church());
///
/// let t3 = || tuple!(1.into_church(), 2.into_church(), 3.into_church());
///
/// assert_eq!(beta(app(pi!(1, 3), t3()), NOR, 0), 1.into_church());
/// assert_eq!(beta(app(pi!(2, 3), t3()), NOR, 0), 2.into_church());
/// assert_eq!(beta(app(pi!(3, 3), t3()), NOR, 0), 3.into_church());
/// # }
/// ```