flâneur — a map of the web's best reading

CSC 151 - Writing your own procedures

eikmeier.sites.grinnell.edu · 2,344 words · saved by 1 readers

As you may recall from the introduction to algorithms, the ability to write subroutines is one of the key components of algorithm design. Subroutines typically have a name that we use to refer to the subroutine, zero or more parameters that provide the input to the subroutine, and a set of instructions (an expression in Scheme) for doing the computation. That is, a subroutine is just an algorithm that has been named and “parameterized”. For example, we might want to define a procedure, square, that takes as input a number and computes the square of that number. As you may have noted, square can have multiple meanings. An aside note: when we choose names in Scheme, we should try not to conflict with existing names (here square is an existing name in Scheme). Sometimes Scheme will stop us from reusing a name; other times it will blithely move along, letting us break things through such reuse. So, how do we define these procedures? Read on and see. Scheme provides a variety of mechanisms

CSC 151 - Writing your own procedures Writing your own procedures Due Wednesday, 10 September 2025 --> Summary We explore why and how to define your own procedures in Scheme. Writing your own procedures In today’s reading, we explore why and how to define your own procedures in Scheme. Introduction As you may recall from the introduction to algorithms, the ability to write subroutines is one of the key components of algorithm design. Subroutines typically have a name that we use to refer to the subroutine, zero or more parameters that provide the input to the subroutine, and a set of instructi

Explore this link on the map →

related reading