about summary refs log blame commit diff stats
path: root/js/games/nluqo.github.io/~bh/61a-pages/Lectures/1.3/keep.scm
blob: be83967d9f8305f1d3ab260a39947d11aff76564 (plain) (tree)






















                                                                             
;;;;;                        cs60a/lectures/1.3/keep.scm
(define (evens nums)
  (cond ((empty? nums) '())
        ((= (remainder (first nums) 2) 0)
         (se (first nums) (evens (bf nums))) )
        (else (evens (bf nums))) ))

(define (ewords sent)
  (cond ((empty? sent) '())
        ((member? 'e (first sent))
         (se (first sent) (ewords (bf sent))) )
        (else (ewords (bf sent))) ))

(define (pronouns sent)
  (cond ((empty? sent) '())
        ((member? (first sent) '(I me you he she it him her we us they them))
         (se (first sent) (pronouns (bf sent))) )
        (else (pronouns (bf sent))) ))

(define (keep pred sent)
  (cond((empty? sent) '())
       ((pred (first sent))(se (first sent)(keep pred (bf sent))))
       (else (keep pred (bf sent)))))