;; The first three lines of this file were inserted by DrScheme. 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 fig.22.1) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ())))
; Figure 22.1

; An empty list has no parts.
(define-struct empty-list ())
; make-empty-list : nothing -> empty-list
; empty-list? : anything -> boolean
; A nelos has two parts: first (a string) and rest (a los).
(define-struct nelos (first rest))
; make-nelos : string los -> nelos
; nelos-first : nelos -> string
; nelos-rest : nelos -> los
; nelos? : anything -> boolean
#|
(define (function-on-nelos L)
; L a nelos
; (nelos-first L) a string
; (nelos-rest L) a los
; (function-on-los (nelos-rest L)) whatever this returns
...)
|#
; A los is either an empty-list or a nelos.
#|
(define (function-on-los L)
; L a los
(cond [(empty-list? L) ...]
[(nelos? L) (function-on-nelos L)]
))
|#
(define nothing (make-empty-list))
(define english (make-nelos "hello" nothing))
(define span-eng (make-nelos "buenos dias" english))
(define heb-span-eng (make-nelos "shalom" span-eng))
(define fhse (make-nelos "bonjour" heb-span-eng))
(define afhse (make-nelos "salaam" fhse))
(define dwarfs (make-nelos "sleepy" (make-nelos "sneezy" (make-nelos "dopey" (make-nelos "doc" (make-nelos "happy" (make-nelos "bashful" (make-nelos "grumpy" nothing))))))))