;; 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-reader.ss" "lang")((modname lect09-dist-struct-intro) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ()))) ;; a book has info: ;; title, author, # of pages, is copyrighted? ; Data Definiton: ; A book is: ; (make-book [string] [string] [natnum] [boolean]) (define-struct book (title author num-pages is-copyrighted?)) ; Examples of the data (make-book "Brevity and Wit" "Barland" 2 #false) (make-book "The Cat in the Hat" "Seuss" 37 #true) ; `define-struct` actually introduces additional functions: ; a constructor ; and four getters ("selectors"). ; In this case, the constructor is named ; make-book ; and the getters are named ; book-title ; book-author ; book-num-pages ; book-is-copyrighted? ;; make a couple examples of the data.