-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14-2.rkt~
35 lines (31 loc) · 999 Bytes
/
14-2.rkt~
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
;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname 14-2) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
; Nelon (nonempty list of numbers) -> Number
; determines the smallest
; number on l
(define (inf l)
(cond
[(empty? (rest l))
(first l)]
[else
(if (< (first l)
(inf (rest l)))
(first l)
(inf (rest l)))]))
; Nelon -> Number
; determines the largest
; number on l
(define (sup l)
(cond
[(empty? (rest l))
(first l)]
[else
(if (> (first l)
(sup (rest l)))
(first l)
(sup (rest l)))]))
(define (most cmp l)
(cond [(empty? (rest l)) (first l)]
[else
(if (cmp (first l) (most cmp (rest l))) (first l) (most cmp (rest l)))]))