Functional Problem Solving (CSC 151 2013F) : Outlines

Outline 31: Numeric Recursion


Held: Tuesday, 29 October 2013

Back to Outline 30 - Naming Local Procedures. On to Outline 32 - Geometric Art Through Numeric Recursion.

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-2013 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.