;(require htdp/testing)
; set the language to pretty big

;; Generate a sentence by appending the pieces together
(define (sentence)
  (append '(the) (noun-phrase) (verb-phrase)))

; given a list, returns a random element of the list
(define (pick-random lst)
  (list-ref lst (random (length lst))))

; takes two functions that take no arguments
; and randomly runs one or the other
(define (either a b)
  (if (= (random 2) 0)
      (a)
      (b)))

;; noun phrase randomly picks between possibilities
(define (noun-phrase)
  (either (lambda ()(list (noun))) 
          (lambda () 
            (list (adjective)
                  (noun)))))


;; noun picks randomly from the noun-list
(define (noun)
  (pick-random noun-list))

(define (adjective)
  (pick-random adjective-list))

;; verb phrase randomly picks between possibilities
(define (verb-phrase)
  (either (lambda () (list (verb))) 
          (lambda () 
            (list (verb)
                  (adverb)))))


(define (verb)
  (pick-random verb-list))

(define (adverb)
  (pick-random adverb-list))

;; define word lists

; note use of quote for whole list
(define noun-list '(dog cat professor student rat))

; this version lists a number of quoted words with 
; same effect
(define verb-list (list 'ran 'ate 'slept 'studied))

(define adjective-list '(red slow funny))

(define adverb-list '(quickly happily well))

;(generate-report)

