; constructor to create a part with no subparts. ; called as (simple-part n) where n is the ; name of the part. (define simple-part (lambda (s) (list 'simple-part s))) ; constructor to create a part with subparts ; called as (complex-part n l) where n is the ; name of the part and l is the list of its ; subparts. (define complex-part (lambda (s l) (list 'complex-part s l))) ; test to determine whether a part has no subparts. (define is-simple? (lambda (s) (eq? (car s) 'simple-part))) ; test to determine whether a part has subparts. (define is-complex? (lambda (s) (eq? (car s) 'complex-part))) ; accessor function that returns the name of a part. (define name-of (lambda (s) (car (cdr s)))) ; accessor function that returns the list of all ; the subparts of a part. if the part is simple, ; this returns the empty list. (define parts-of (lambda (s) (if (is-simple? s) '() (car (cdr (cdr s)))))) ; here is a simple example of how to use the constructors ; to create a representation of a whole that is made up ; of parts. (define basic-doric-form (complex-part 'doric-form (list (simple-part 'entablature) (simple-part 'column) (simple-part 'pedestal)))) ; here is a complex example of how to use the constructors ; to create a representation of a whole that is made up of ; parts. (define full-doric-form (complex-part 'doric-form (list (complex-part 'entablature (list (simple-part 'cornice) (simple-part 'frieze) (simple-part 'architrave))) (complex-part 'column (list (complex-part 'capital (list (complex-part 'abacus (list (simple-part 'fillet) (simple-part 'cymation) (simple-part 'plinth))) (complex-part 'necking (list (simple-part 'fillets) (simple-part 'astragal) (simple-part 'cincture))))) (simple-part 'shaft) (simple-part 'column-base))) (complex-part 'pedestal (list (simple-part 'cap) (simple-part 'dado) (simple-part 'base))))))