Skip to content
scrambled
Programming Language Theory Flashcard

What

Books Concepts Deckpure-lambda-calculus

Question

What's special about the church encoding of numbers and lists?

Answer

  • Both have a base value:

    • Number: 0.

    • List: Empty list.

  • Both have an operation to "step" up a value that can cover the whole value universe of the type:

    • Number: +1.

    • List: cons with a value.

  • With this, we can encode numbers and lists as:

    • Number: λa. λz. a (a (a ... z)).

      • a stands for increment.

      • z stands for zero.

        -> A number n roughly means applying increment n times to zero.

    • List: λc. λl. c e0 (c e1 (c e2 ... l)) .

      • c stands for cons.

      • l stands for empty list.

        -> A list roughly means applying cons with a value n times to the empty list.