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.13) (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 ;; maxi : non-empty-lon -> number
5 ;; to determine the largest number on alon
6 (define (maxi alon)
7 (cond
8 [(empty? (rest alon)) (first alon)]
9 [else (cond
10 [(> (first alon) (maxi (rest alon))) (first alon)]
11 [else (maxi (rest alon))])]))
13 (define (maxi2 alon)
14 (cond
15 [(empty? (rest alon)) (first alon)]
16 [else (local ((define r (maxi2 (rest alon))))
17 (cond
18 [(> (first alon) r) (first alon)]
19 [else r]))]))
21 #|
22 (maxi (list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35))
23 (maxi2 (list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35))
24 |#