;; An LOS (list of strings) is one of: ;; - empty ;; - (cons String LOS) #;(define (los-temp an-los) (cond [(empty? an-los) ...] [else ... (first an-los) ... (los-temp (rest an-los)) ... ])) ;; Examples (check-expect (sum-lengths empty) 0) (check-expect (sum-lengths (cons "hi" empty)) 2) (check-expect (sum-lengths (cons "world" (cons "hi" empty))) 7) (check-expect (sum-lengths (cons "northeastern" (cons "hi" empty))) 14) ;; sum-lengths : LOS -> Number ;; sum up the lengths of all the strings in los (define (sum-lengths los) (cond [(empty? los) 0] [else (+ (string-length (first los)) (sum-lengths (rest los)))])) ;-------------------------------------------------------------------- ;; in? : LOS String -> Boolean ;; Is the string s in list los? (define (in? los s) (cond [(empty? los) false] [else (or (string=? (first los) s) (in? (rest los) s))])) (check-expect (in? empty "Ben") false) (check-expect (in? (cons "hi" empty) "hi") true) (check-expect (in? (cons "hi" empty) "hello") false) (check-expect (in? (cons "world" (cons "hi" empty)) "worl") false)