Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Lambda calculus
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Pairs === A pair (2-tuple) can be defined in terms of {{Mono|TRUE}} and {{Mono|FALSE}}, by using the [[Church encoding#Church pairs|Church encoding for pairs]]. For example, {{Mono|PAIR}} encapsulates the pair ({{Mono|''x''}},{{Mono|''y''}}), {{Mono|FIRST}} returns the first element of the pair, and {{Mono|SECOND}} returns the second. : {{Mono|1=PAIR := 位''x''.位''y''.位''f''.''f'' ''x'' ''y''}} : {{Mono|1=FIRST := 位''p''.''p'' TRUE}} : {{Mono|1=SECOND := 位''p''.''p'' FALSE}} : {{Mono|1=NIL := 位''x''.TRUE}} : {{Mono|1=NULL := 位''p''.''p'' (位''x''.位''y''.FALSE)}} A linked list can be defined as either NIL for the empty list, or the {{Mono|PAIR}} of an element and a smaller list. The predicate {{Mono|NULL}} tests for the value {{Mono|NIL}}. (Alternatively, with {{Mono|1=NIL := FALSE}}, the construct {{Mono|''l'' (位''h''.位''t''.位''z''.deal_with_head_''h''_and_tail_''t'') (deal_with_nil)}} obviates the need for an explicit NULL test). As an example of the use of pairs, the shift-and-increment function that maps {{Mono|(''m'', ''n'')}} to {{Mono|(''n'', ''n'' + 1)}} can be defined as : {{Mono|1=桅 := 位''x''.PAIR (SECOND ''x'') (SUCC (SECOND ''x''))}} which allows us to give perhaps the most transparent version of the predecessor function: : {{Mono|1=PRED := 位''n''.FIRST (''n'' 桅 (PAIR 0 0)).}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)