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.15) (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 (define-struct ir (name price))
6 ;An inventory-record (ir) is a structure
7 ;(make-ir n p)
8 ;where n is a symbol and p is a number.
10 ;; extract1 : inventory -> inventory
11 ;; to create an inventory from an-inv for all
12 ;; those items that cost less than $1
13 (define (extract1 an-inv)
14 (cond
15 [(empty? an-inv) empty]
16 [else (cond
17 [(<= (ir-price (first an-inv)) 1.00)
18 (cons (first an-inv) (extract1 (rest an-inv)))]
19 [else (extract1 (rest an-inv))])]))