Functional Problem Solving (CSC 151 2014F) : EBoards

CSC151.01 2014F, Class 34: Iteration


Overview

Preliminaries

Admin

Upcoming Work

Cool Upcoming Events on Campus

Extra Credit Opportunities

Academic

Peer Support

Notes on the Quiz

There was enough difficulty on the quiz that it seems worth going over.

Problem 1

(define iota
  (lambda (num)
    (if (not (and (number? num)
                  (not (negative? num))
                  (integer? num)))
        (error "iota expected a non-negative integer, given " num)]
        (let kernel ([counter 0])
          (if _______________
              null
              (cons _______________  (kernel ___________________)))))))

Problem 2

(define whatzitdo
  (lambda (vals)
    (and (not (null? vals))
         (or (odd? (car vals))
             (whatzitdo (cdr vals))))))

Followup

Questions

Contrasting map, for-each, repeat, and recursion

Lab