1 ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 ;; about the language level of this file in a form that our tools can easily process.
3 #reader(lib "htdp-intermediate-reader.ss" "lang")((modname 21.2.1) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp")))))
4 (local ((define (f x) x))
7 (local ((define (f x) (+ 1 x)))
15 ;evens : N [>=0] -> (listof N [>=0])
16 Given n, evens creates a list of the first n even numbers.
19 (local ((define (evens n)
27 Exercise 21.2.1. Use build-list
29 to define evens, which consumes a natural number n and creates the list of the first n even numbers;
31 to define tabulate from exercise 21.1.1; and
33 to define diagonal, which consumes a natural number n and creates a list of lists of 0 and 1.
41 Use local if function definitions require auxiliary functions. Solution
43 ;; build-list : N (N -> X) -> (listof X)
44 ;; to construct (list (f 0) ... (f (- n 1)))
45 (define (build-list n f) ...)