UNB/ CS/ David Bremner/ teaching/ cs3613/ tutorials/ quick

Squaring the Circle.


Functions as values

Complete Part 6 of the Quick Tutorial because the function series defined there was used in part 7.

Let's try and reduce the repeated code in this definition.

(define (series mk)
  (hc-append 4 (mk 5) (mk 10) (mk 20)))

Initial attempt fails. What to add?

(define (series2 mk)
  (hc-append 4 (map mk '(5 10 20))))

This really starts to pay off with more repetition

(define (series3 mk)
  (apply hc-append 1 (build-list 100 mk)))

Functions, Scope, and Lists