Design Pattern for Recursive Functions
A design pattern is an abstracted way of writing programs of a certain kind. By learning useful design patterns, you can write programs faster and with fewer errors.
A design pattern for recursive functions is:
(defun myfun (arg)
         (if (basecase? arg)
                 (baseanswer arg)
                 (combine arg (myfun
(smaller arg)))))
In this pattern,
Exercise: Show how the factorial function corresponds to this design pattern.
Contents    Page-10    Prev    Next    Page+10    Index