Test List Content
;
; Tell if a list consists entirely of strings by recursively checking each
; member.
(define (all-strings? lis)
(if (null? lis)
#t
(if (str? (car lis))
(all-strings? (cdr lis))
nil
)
)
)
;
; Tell if the members of a list are all strings by mapping str? to each
; member, adding 'and to the front of the list, then evaluating it as
; a giant and expression.
(define (all-strings-b? lis) (eval (cons 'and (map str? lis))))
;
; A generalization of all-strings? that can test for any condition by
; accepting a test function instead of using only str?
(define (all-whatever? f? lis)
(if (null? lis)
#t
(if (f? (car lis))
(all-whatever? f? (cdr lis))
nil
)
)
)