We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Several ways have been proposed for representing the natural numbers in
the pure lambda calculus. In each case, cardinal values are encoded as patterns
in function definitions. Our approach will be to code a natural number
by the number of times a function parameter is applied:
define 0 = λf . λx . x
define 1 = λf . λx . f x
define 2 = λf . λx . f (f x)
define 3 = λf . λx . f (f (f x)) and so on.
I hope this helps. So 47 is the answer you are looking for. :)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lambda Calculus - Evaluating Expressions #3
You are viewing a single comment's thread. Return to all comments →
From: http://homepage.cs.uiowa.edu/~slonnegr/plf/Book/Chapter5.pdf
Several ways have been proposed for representing the natural numbers in the pure lambda calculus. In each case, cardinal values are encoded as patterns in function definitions. Our approach will be to code a natural number by the number of times a function parameter is applied:
define 0 = λf . λx . x
define 1 = λf . λx . f x
define 2 = λf . λx . f (f x)
define 3 = λf . λx . f (f (f x)) and so on.
I hope this helps. So 47 is the answer you are looking for. :)