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 ;An inventory is either
11 ;1. empty or
12 ;2. (cons ir inv)
13 ;where ir is an inventory record (ir) and inv is an inventory.
15 ;; extract1 : inventory -> inventory
16 ;; to create an inventory from an-inv for all
17 ;; those items that cost less than $1
18 (define (extract1 an-inv)
19 (cond
20 [(empty? an-inv) empty]
21 [else
22 (local ((define fi (first an-inv))
23 (define ex (extract1 (rest an-inv))))
24 (cond
25 [(<= (ir-price fi) 1.00)
26 (cons fi ex)]
27 [else ex]))]))
29 (define INV (list (make-ir 'JumpingJacks 0.75)
30 (make-ir 'LaserPen 0.99)
31 (make-ir 'BowlingPin 1.25)
32 (make-ir 'NightLite 0.45)
33 (make-ir 'Telescope 5.50)
34 (make-ir 'Pogs 0.50)))