问题
I'm trying to implement a Church Pair Lambda Calc. style with CLisp.
According with Wikipedia:
pair ≡ λx.λy.λz.z x y
So far, this is my code:
(defvar PAIR
#'(lambda(x)
#'(lambda(y)
#'(lambda(z)
(funcall (funcall z x) y)))) )
These are my FIRST and SECOND Functions:
(defvar FIRST
#'(lambda(p)
(funcall(p TRUE)))
)
(defvar SECOND
#'(lambda(p)
(funcall(p FALSE)))
)
This 2 functions convert from Int to ChurchNumber
(defun church2int(numchurch)
(funcall (funcall numchurch #'(lambda (x) (+ x 1))) 0)
)
(defun int2church(n)
(cond
((= n 0) #'(lambda(f) #'(lambda(x)x)))
(t #'(lambda(f) #'(lambda(x) (funcall f
(funcall(funcall(int2church (- n 1))f)x))))))
)
So, what I do is:
(setq six (int2church 6))
(setq four (int2church 4))
And then:
(setq P (funcall (funcall PAIR six) four))
And the I've got:
#<FUNCTION :LAMBDA (Y) (FUNCALL (FUNCALL F X) Y)>
So if I do this:
(funcall #'FIRST P)
I've got the this error:
*** - FIRST: #<FUNCTION :LAMBDA (Y) (FUNCALL (FUNCALL F X) Y)> is not a list
I can't see what I am doing wrong. Any help would be appreciated.
Thanks
回答1:
We understand there are some folks upset about the decision made this week. We aren’t going to share specifics out of respect for all individuals involved but this is a site reaching millions of people and we have to do what we believe fosters a spirit of inclusion and respect. When a moderator violates that, we will always do our best to resolve it with them privately. When we can’t we must take action. This is always done based on what we believe is best for all SE users.
来源:https://stackoverflow.com/questions/13537622/lambda-calculus-cons-pair-implementation-with-lisp