Blob


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 18.1.1) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "dir.ss" "teachpack" "htdp") (lib "hangman.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "dir.ss" "teachpack" "htdp") (lib "hangman.ss" "teachpack" "htdp")))))
4 (local (
5 (define x (* y 3))
6 )
8 (* x x))
10 (local (
12 (define (odd an)
13 (cond
14 [(zero? an) false]
15 [else (even (sub1 an))]))
18 (define (even an)
19 (cond
20 [(zero? an) true]
21 [else (odd (sub1 an))])))
24 (even a-nat-num))
26 (local (
28 (define (f x) (g x (+ x 1)))
29 (define (g x y) (f (+ x y)))
31 )
34 (+ (f 10) (g 10 20))
36 )
38 (local (
39 (define x 10)
40 (y (+ x x)))
41 y)
43 (local (
45 (define (f x) (+ (* x x) (* 3 x) 15))
46 (define x 100)
47 (define f@100 (f x))
49 )
52 f@100 x)
54 (local (
55 (define (f x) (+ (* x x) (* 3 x) 14))
56 (define x 100)
57 (define f (f x)))
58 f)
60 1. (define A-CONSTANT
61 (not
64 (local (
66 (define (odd an)
67 (cond
68 [(= an 0) false]
69 [else (even (- an 1))]))
72 (define (even an)
73 (cond
74 [(= an 0) true]
75 [else (odd (- an 1))]))
77 )
80 (even a-nat-num)
82 )
84 ))
85 2. (+
88 (local (
92 (define (f x) (+ (* x x) (* 3 x) 15))
93 (define x 100)
94 (define f@100 (f x))
98 )
99 f@100)
103 1000)
104 3. (local (
107 (define CONST 100)
108 (define f x (+ x CONST))
115 (define (g x y z) (f (+ x (* y z))))
121 = (define (D x y)
122 (local ((define x2 (* x x))
123 (define y2 (* y y)))
124 (sqrt (+ x2 y2))))
125 (+ (local ((define x2 (* 0 0))
126 (define y2 (* 1 1)))
127 (sqrt (+ x2 y2)))
128 (D 3 4))
130 ;; sort : list-of-numbers -> list-of-numbers
131 (define (sort alon)
132 (local (
134 (define (sort alon)
135 (cond
136 [(empty? alon) empty]
137 [(cons? alon) (insert (first alon)
138 (sort (rest alon)))]))
141 (define (insert an alon)
142 (cond
143 [(empty? alon) (list an)]
144 [else (cond
145 [(> an (first alon)) (cons an alon)]
146 [else (cons (first alon)
147 (insert an (rest alon)))])]))
150 (sort alon)))