let-forms are allowed to contain several expressions inside:
(let ((x 4))
x
(+ x 1))
returns 5.
How is this expression evaluated?
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 situation you’re describing occurs in several parts in Scheme, not only in a
letexpression. In the following …letexpressionlambdaexpression (and consequently, after the list of parameters in a procedure definition)condexpression… you can write a list of expressions. Implicitly those expressions are enclosed inside a
beginspecial form, the order of evaluation is from left to right, all the expressions are evaluated in turn but the value returned is that of the last expression.For example, this expression:
Is equivalent to:
In both cases, the returned value is
3, because that’s the value of the last expression in the list.