I am VERY new to scheme. Very basic question for everyone. What is lambda in function calls I see everywhere online? What does it do? What do I lose by not using it?
Share
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.
lambdais a special form in the family of Lisp programming langauges (and in other languages with some degree of support for functional programming), it’s an anonymous function that creates a closure around the context in which it was defined.Lambdas are used everywhere in Lisp, either explicitly or implicitly (behind macro transformations, implicitly in other special forms, etc.) What would you lose by not using it? Everything. For starters, the ability to define procedures!
To see some examples of what I mean, this procedure definition:
… Is just syntactic sugar for this, a named procedure that simply associates a name to the anonymous
lambda:Similarly, the
letform that binds values to variables:… Is just syntactic sugar for this:
Of course, lambdas can be used as a quick way to define anonymous functions:
Truth be told, it’s almost impossible not to use lambdas for writing any non-trivial program in Lisp.