;; A LOS (List of Strings) is one of: ;; - empty ;; - (cons String LOS) ;; LOS -> ? #;(define (los-temp an-los) (cond [(empty? an-los) ...] [(cons? an-los) ... (first an-los) ... (los-temp (rest an-los))... ])) ;; count : LOS -> Number ;; count the number of strings in given list (define (count los) (cond [(empty? los) 0] [(cons? los) (+ 1 (count (rest los)))])) (define los1 empty) (define los2 (cons "Jacob" empty)) (define los3 (cons "Sean" los2)) (check-expect (count los1) 0) (check-expect (count los2) 1) (check-expect (count los3) 2) ;; total-len : LOS -> Number ;; sum up lengths of all strings in list (define (total-len los) (cond [(empty? los) 0] [(cons? los) (+ (string-length (first los)) (total-len (rest los)))])) (check-expect (total-len los1) 0) (check-expect (total-len los2) 5) (check-expect (total-len los3) 9) ;; in? : LOS String -> Boolean ;; Is the string s in the list los? (define (in? los s) (cond [(empty? los) false] [(cons? los) (or (string=? (first los) s) (in? (rest los) s))])) (check-expect (in? los1 "Sean") false) (check-expect (in? los2 "Sean") false) (check-expect (in? los3 "Sean") true)