8.31.2006
5:22 AM

In a belated response to netytan, I post my own any? and all? written in Scheme.

(define (any? proc ls)
    (if (null? ls)
        #f
        (if (proc (car ls))
            #t
            (any? proc (cdr ls)))))

;; (any? even? '(1 3 5 8 7)) => #t, shortcircuiting at 8
;; (any? odd?  '(2 4 6 8 10)) => #f

(define (all? proc ls)
    (if (null? ls)
        #t
        (if (proc (car ls))
            (all? proc (cdr ls))
            #f)))

;; (all? even? '(2 4 6 1 2 3)) => #f, shortcircuiting at 1
;; (all? odd?  '(1 3 5 7 9 11)) => #t

Just because.


8:23 AM
I remember doing something like that in my senior year in college. We only used it for a few courses, and everybody got frustrated because of the myriad parentheses involved.

Your formula is definitely solid, though. I'd test it myself if I had a Scheme/Lisp interpreter. Good work.