Blame


1 12687dd9 2023-08-04 jrmu ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 12687dd9 2023-08-04 jrmu ;; about the language level of this file in a form that our tools can easily process.
3 12687dd9 2023-08-04 jrmu #reader(lib "htdp-intermediate-reader.ss" "lang")((modname 21.1.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 12687dd9 2023-08-04 jrmu Exercise 21.1.1. Define tabulate, which is the abstraction of the following two functions:
5 12687dd9 2023-08-04 jrmu
6 12687dd9 2023-08-04 jrmu ;; tabulate-sin : number -> lon
7 12687dd9 2023-08-04 jrmu ;; to tabulate sin between n
8 12687dd9 2023-08-04 jrmu ;; and 0 (inclusive) in a list
9 12687dd9 2023-08-04 jrmu (define (tabulate-sin n)
10 12687dd9 2023-08-04 jrmu (cond
11 12687dd9 2023-08-04 jrmu [(= n 0) (list (sin 0))]
12 12687dd9 2023-08-04 jrmu [else
13 12687dd9 2023-08-04 jrmu (cons (sin n)
14 12687dd9 2023-08-04 jrmu (tabulate-sin (sub1 n)))]))
15 12687dd9 2023-08-04 jrmu
16 12687dd9 2023-08-04 jrmu ;; tabulate-sqrt : number -> lon
17 12687dd9 2023-08-04 jrmu ;; to tabulate sqrt between n
18 12687dd9 2023-08-04 jrmu ;; and 0 (inclusive) in a list
19 12687dd9 2023-08-04 jrmu (define (tabulate-sqrt n)
20 12687dd9 2023-08-04 jrmu (cond
21 12687dd9 2023-08-04 jrmu [(= n 0) (list (sqrt 0))]
22 12687dd9 2023-08-04 jrmu [else
23 12687dd9 2023-08-04 jrmu (cons (sqrt n)
24 12687dd9 2023-08-04 jrmu (tabulate-sqrt (sub1 n)))]))
25 12687dd9 2023-08-04 jrmu Be sure to define the two functions in terms of tabulate. Also use tabulate to define a tabulation function for sqr and tan. What would be a good, general contract? Solution