This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: (if (empty? list) false (or (pred (first list)) (any pred (rest list))) ) ) ;(define (any-zero list) (any zero? list)) ;(define (any-one list) (any is-one list)) (define (any-positive list) (any positive? list)) ;** can pass function as parameter and use it ; (filter positive? my-list) ; filter gives list of all the ones which that predicate is true (define (inc x) (+ x 1)) (define (square x) (* x x)) (define (positive x) (> x 0)) (define (negative x) (< x 0)) (define my-list (list 1 -2 3 -4 5 -6 7)) (define (all pred list) (= (length list) (length (filter pred list)))) (map inc (map square my-list)) (foldl + 0 my-list) (foldl + 0 (map square my-list)) (define string-list (list "hello" "goodbye" "caio" "aloha")) (foldr string-append "" string-list) (foldl string-append "" string-list)...
View Full Document
- Winter '09