CSC 151 - Anonymous procedures
You’ve learned the most common approach we will use to defining procedures. To define a procedure, you use a form like the following. If we wanted to define a procedure, add, that adds two values, we might write something like the following. However, you’ve already seen another way to define a procedure. Instead of the lambda expression, you can use define to give another name to a procedure that already exists. For example, How are these two definitions similar? Both use the define keyword to associate a name (add) with something that defines a procedure. In the first case, it’s a lambda expression. In the second, it’s an existing procedure. Perhaps that’s not surprising. We can also define numeric values using expressions or constants. The Lisp family of languages (including Scheme) set themselves apart from many programming languages by permitting you to use a variety of kinds of expressions to define procedures. You’ve already seen two: lambda expressions and existing procedures. I
CSC 151 - Anonymous procedures Anonymous procedures Due Wednesday, 17 September 2025 --> Summary While lambda expressions are the most common way to write procedures, there are also a variety of others. We consider how to use composition and sectioning to build new procedures from old. Introduction You’ve learned the most common approach we will use to defining procedures. To define a procedure, you use a form like the following. ( define <identifier> ( lambda ( <arguments> <expression> ))) If we wanted to define a procedure, add , that adds two values, we might write something like the follow
Explore this link on the map →saved by
related reading
- CSC 151 - Naming values with local bindingseikmeier.sites.grinnell.edu
- CSC 151 - Higher-order design, recursive and othereikmeier.sites.grinnell.edu
- CSC 151 - The "big three" list operationseikmeier.sites.grinnell.edu
- CSC 151 - Code Formatting and Styleeikmeier.sites.grinnell.edu
- CSC 151 - Analyzing procedureseikmeier.sites.grinnell.edu
- CSC 151 - Conditional evaluation in Schemeeikmeier.sites.grinnell.edu
- CSC 151 - Transforming listseikmeier.sites.grinnell.edu
- CSC 151 - Decompositioneikmeier.sites.grinnell.edu
- CSC 151 - Coding Challenge 7eikmeier.sites.grinnell.edu
- CSC 151 - Recursion over Numberseikmeier.sites.grinnell.edu
- Structure and Interpretation of Computer Programsmitp-content-server.mit.edu
- Structure and Interpretation of Computer Programsmitp-content-server.mit.edu