Functional Problem Solving (CSC 151 2014F) : EBoards

CSC151.01 2014F, Class 26: Recursion with Helper Procedures


Overview

Preliminaries

Admin

Upcoming Work

Extra Credit Opportunities

Academic

Peer Support

Questions

Did you change the exam?

I added some Q&A.

I added some notes on problem 7.

But the questions themselves did not change.

Can you explain problem 7?

Yes. I'll go over it.

How do I get under 11 "words" in that evil problem?

Look at the reading on anonymous procedures.

Basics of helper recursion

Strategy for building these kinds of recursive procedures

Choices of problems to try

We've run out of elements, keep extracted list

    (define extract-evens
      (lambda (lst)
        (extract-evens-helper lst null)))

    (define extract-evens-helper
      (lambda (remaining extracted)
        (if (null? remaining)
            extracted
            (exract-evens-helper (cdr remaining)
                                 (if (even? (car remaining))
                                     (cons (car remaining) extracted)
                                     extracted)))))

A term: Tail recursion