Functional Problem Solving (CSC 151 2014F) : EBoards

CSC151.01 2014F, Class 36: Trees


New partners! * Grab a card. * Read it, figure out where you go. * Put the card on the plate so that Evan doesn't have to collect it.

Overview

Preliminaries

Admin

Upcoming Work

Cool Upcoming Events on Campus

Extra Credit Opportunities

Academic

Peer Support

Questions/Recent Ideas/Etc.

When do you use basic recursion and when do you use helper recursion?

Husk-and-kernel does one kind of helper recursion, but I think you mean the question more generally.

No general answer (at least not one that I know of). It's mostly which way makes it easier to think about solving the particular problem.

If I find it "natural" to have one or more extra values during your recursion, I start with helper.

I often end up writing whichever feels easier, and then go back and reflect on whether I might improve.

Looking at/remembering similar kinds of problems helps.

How do we write listp?

A list is either the empty list (i.e., null) or a pair whose cdr is a list.

    (define listp?
      (lambda (val)
        (or (null? val)
            (and (pair? val)
                 (listp? (cdr val))))))

Is the null list a pair?

No, it is the only list that is not a pair.

Four Kinds of Repetition

What's the relationship between the four kinds of somewhat general repetition? (for-each, map, repeat, recursion)`

Things we came up with

Lab

Debrief