Functional Problem Solving (CSC 151 2014S) : Outlines

Outline 28: Numeric Recursion


Held: Friday, 7 March 2014

Back to Outline 27 - Other Forms of List Recursion. On to Outline 29 - Pause for Breath.

Summary

We visit a slightly different kind of recursion, numeric recursion. In this technique, we once again have procedures call themselves. However, the parameter that we "simplify" at every step is a number, rather than a list.

Related Pages

Overview

Administrivia

Patterns of Recursion

While we've seen and written a variety of examples of direct recursion, they typically have the following form:

(define *recursive-proc*
  (lambda (*params*)
    (if (*base-case-test*)
        (*base-case* *params*)
        (*combine* (*partof* *params*)
                   (*recursive-proc* (*simplify* *params*))))))

For lists, the simplification was almost always "take the cdr" and the "part-of" was almost always "take the car".

Recursion with Numbers

Lab


Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright (c) 2007-2014 Janet Davis, Samuel A. Rebelsky, and Jerod Weinman. (Selected materials are copyright by John David Stone or Henry Walker and are used with permission.)

Creative Commons License

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/3.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.