In scheme, why is this:
(define foo
(lambda (x)
42))
considered better style than this:
(define (foo x)
42)
And is there any reason to favour one over the other?
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.
I don’t think that’s considered better style, the first is redundant. The real question is whether you define the named function
fooor just uselambdainstead. If you’ve already decided to make a named functionfoothen I don’t see why you would put thelambdainside.lambdarelieves you of having to separately name and define every little function you make, so that’s really where the decision is: is this function important enough to be defined and named separately.