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-beginner-reader.ss" "lang")((modname 11.2.3) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp")))))
6 ;2. (add1 n) where n is a natural-number.
10 ;2. (cons s los) where s is a symbol and
11 ;los is a list-of-symbols.
13 ;repeat : natural-number symbol -> list-of-symbols
14 ;Given a natural-number n, returns word n times
15 ;as a list-of-symbols.
18 ;(define (repeat n word)
21 ; [else ... (repeat (sub1 n)) ...]))
23 (define (repeat n word)
26 [else (cons word (repeat (sub1 n) word))]))
28 ;; f : number -> number
34 ;A list-of-posns is either
36 ;2. (cons p lop) where p is a posn and lop is a list-of-posns.
37 ;tabulate-f : natural-number -> list-of-posns
38 ;Creates a "table". Returns a list of n posns of the form
39 ;(cons (make-posn (f n) n) (cons (make-posn (f (- n 1) (- n 1)))...
41 (define (tabulate-f n)
44 [else (cons (make-posn (f n) n) (tabulate-f (sub1 n)))]))