;;; extract-positives : list-of-number -> list-of-number
;;; consumes list of num and produces list of all positive nums in list
;;;  (uses built-in operator positive?)
;(define (extract-positives alon)
;  (cond [(empty? alon) empty]
;        [(cons? alon) 
;           (cond [(positive? (first alon)) 
;                    (cons (first alon) (extract-positives (rest alon)))]
;                 [else (extract-positives (rest alon))])]))
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;;; short-strings : number list-of-string -> list-of-string
;;; consumes num and list of string and produces list of all strings 
;;; shorter than given num
;(define (short-strings limit alos)
;  (cond [(empty? alos) empty]
;        [(cons? alos) 
;           (cond [(< (string-length (first alos)) limit)
;                    (cons (first alos) (short-strings limit (rest alos)))]
;                 [else (short-strings limit (rest alos))])]))
;
;;; FILTER IS BUILT-IN TO DR RACKET
;   ;; filter : (alpha -> boolean) list[alpha] -> list[alpha]
;   ;; extracts elements of list for which given keep function returns true
;   (define (filter keep? alst)
;     (cond [(empty? alst) empty]
;           [(cons? alst)
;            (cond [(keep? (first alst)) 
;                   (cons (first alst) (filter keep? (rest alst)))]
;                  [else (filter keep? (rest alst))])]))
;

;; extract-positives : list-of-number -> list-of-number
;; consumes list of num and produces list of all positive nums in list
(define (extract-positives alon)
  (filter positive? alon))


;; short-strings : number list-of-string -> list-of-string
;; consumes num and list of string and produces list of all strings shorter than given num
(define (short-strings limit alos)
  (local [(define (short? astr) (< (string-length astr) limit))]
    (filter short? alos)))

;; a dillo is a (make-dillo number boolean)
(define-struct dillo (length dead?))



(define DILLOS (list (make-dillo 3 true)
                     (make-dillo 3 false)
                     (make-dillo 5 false)
                     (make-dillo 7 false)
                     (make-dillo 7 true)))

;; dead-dillos:  list-of-dillo -> list-of-dillo
;; produces a list of the dead dillos
(define (dead-dillos alod)
  (filter dillo-dead? alod))



;; live-dillos:  list-of-dillo -> list-of-dillo
;; produces a list of the live dillos
(define (live-dillos alod)
    (filter alive? alod))

;; alive?:  dillo -> boolean
;; consumes a dillo and produces true if the dillo is alive
(define (alive? a-dillo)
  (not (dillo-dead? a-dillo)))


;; short-and-dead:  list-of-dillo number -> list-of-dillo
;; produces a list of dead dillos less than the given length
(define (short-and-dead alod max-length)
  (local [(define (short-dead? a-dillo)
            (and (< (dillo-length a-dillo) max-length)
                 (dillo-dead? a-dillo)))]
    (filter short-dead? alod)))