I am trying to write an or
function in Scheme
(define or
(lambda (p q) p p q))
If I do (or #t #f)
I get #f
.
What is the problem in what I am doing?
I saw λpq.ppq
in a video on youTube.
I am trying to write an or
function in Scheme
(define or
(lambda (p q) p p q))
If I do (or #t #f)
I get #f
.
What is the problem in what I am doing?
I saw λpq.ppq
in a video on youTube.
The correct Lambda Calculus definitions are
(note the parens!). But
#t
and#f
won't work with these. They expectYou can check it with
With your definition there's a set of parentheses missing:
It reduces as:
To cause an application of
p
top
andq
we need to enclose the form in parentheses, like this:(p p q)
. Without them you just have three consecutive expressions, three variables, and only the last one's value is returned, as is, as the overall result. Which is the value ofq
. Which is#f
.