1.2  Example: Data definition for structures

;; A Posn is a structure: Number Number
;; (define posn (x y) --- this definition already exists in DrScheme

;; An Auto is a structure: String Number Number
(define-struct auto (model tank-size mpg))

;; Examples: defining data using the constructors
(define p1 (make-posn 10 20))
(define p2 (make-posn 30 20))

(define auto1 (make-auto "Ford" 15 20))
(define auto2 (make-auto "VW" 12 15))

;; Retrieving fields of structures using the selectors:
(equal? 10 (posn-x p1))
(= 20 (posn-y p2))

(equal? "Ford" (auto-model auto1))
;(= "VW" (auto-model auto2)) Note: = compares only numbers
(= 15 (auto-tank-size auto1))
(= 15 (auto-mpg auto2))