CSC 151 - Higher-order design, recursive and other
After writing many recursive functions you may have noticed general patterns in the code you wrote. For example, calculating the length of a list: That should look similar to summing the elements of a list: Which, with a little bit of eye-contortion, is similar to appending lists: In all three cases: In the spirit of functions-as-abstractions, can we write a function that captures this generic behavior? This line of investigation leads us back to the big three list functions, map, filter, and reduce! We motivate the design of higher-order recursive functions by examining their implementation and discuss their limitations in more detail. Recall that (map fun lst) returns a new list in which each element is the corresponding element of lst transformed by unary function fun. For example, we can (map increment nums) to increment all the elements of nums by 1 or we can (map zero? nums) to turn every element of l into a boolean denoting whether that element was zero. How can we implement map
CSC 151 - Higher-order design, recursive and other Higher-order design, recursive and other Due Wednesday, 29 October 2025 --> Summary In this reading, we apply recursive design to higher-order procedures, revisiting the big three list functions: map, filter, and reduce. After writing many recursive functions you may have noticed general patterns in the code you wrote. For example, calculating the length of a list: (define length (lambda (lst) (match lst [null 0] [(cons head tail) (+ 1 (length tail))]))) That should look similar to summing the elements of a list: (define sum (lambda (lst) (mat
Explore this link on the map →saved by
related reading
- CSC 151 - The "big three" list operationseikmeier.sites.grinnell.edu
- CSC 151 - Recursion Over Listseikmeier.sites.grinnell.edu
- CSC 151 - Transforming listseikmeier.sites.grinnell.edu
- CSC 151 - Recursion over Numberseikmeier.sites.grinnell.edu
- CSC 151 - Coding Challenge 6eikmeier.sites.grinnell.edu
- CSC 151 - Tail Recursioneikmeier.sites.grinnell.edu
- CSC 151 - Analyzing procedureseikmeier.sites.grinnell.edu
- CSC 151 - Pattern matchingeikmeier.sites.grinnell.edu
- CSC 151 - Coding Challenge 4eikmeier.sites.grinnell.edu
- CSC 151 - Coding Challenge 8eikmeier.sites.grinnell.edu
- CSC 151 - Coding Challenge 7eikmeier.sites.grinnell.edu
- CSC 151 - Anonymous procedureseikmeier.sites.grinnell.edu