I have this piece of scheme code:
(define (x . y) y)
(x 1 2 3)
and I know it equivalent to:
'(1 2 3)
But i can’t understand why.
What does the first line of code do?
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first line
(define (x . y) y)is equivalent to(define x (lambda y y)), according to 5.2 Definitions(the last clause).And
(lambda y y)is a procedure; when called all the arguments will stored in a newly allocated list. e.g.listcould be defined as(define list (lambda xs xs)). (See 4.1.4 Procedures the second form of formal parameters.)So
(x 1 2 3)is equivalent to(list 1 2 3).