Index: List and structure examples, HTML library
There are too many examples here to do all during lab. Instead, do some from each group during lab, and the rest on your own. We will continue with these and similar examples in the next lab, so that you get lots of practice.
Important for all examples:
In class, we've defined, e.g.,
; a list-of-symbols is one of ; - empty ; - (make-lst f r), where f is a symbol, and r is a list-of-symbols (define-struct lst (first rest))and then used make-lst, lst-first, lst-rest, and lst?. Using lists is so common that Scheme has these functions built in, except using different names. Instead, write
; a list-of-symbols is one of ; - empty ; - (cons f r), where f is a symbol, and r is a list-of-symbolsand use cons, first, rest, and cons?.
To do: First, copy the following into a file db.ss.
;; Some basic constants: (define MAX-SALARY 1000000) (define MIN-SALARY 20000) (define MIN-AGE 18) (define MAX-AGE 65) ;; A database record is ;; (make-record symbol a s) ;; where a is an integer between MIN-AGE and MAX-AGE (inclusive) ;; and s is an integer between MIN-SALARY and MAX-SALARY (inclusive) (define-struct record (name age salary)) ;; A database is a list of database records, i.e., one of ;; - empty ;; - (cons f r) ;; where f is a database record, r is a database
% db Man 23 120000 BigMan 46 800000 Little 19 30000 Woman 32 300000 Kiddo 18 20000That's just a simple example to show you that Scheme programs can be executed from the Unix prompt (on Owlnet), rather than in DrScheme. They can also be run directly in Windows and MacOS, but we won't get into those details here.
To prepare for assignment 3, read the overview of the HTML library. For each of the following, look at only the individual data definitions needed by each problem.