predicates.scm 456 B

1234567891011121314151617181920212223242526
  1. (define-module (predicates)
  2. #:export (any-pred? all-pred?))
  3. (use-modules
  4. ;; for fold
  5. (srfi srfi-1))
  6. (define any-pred?
  7. (λ (lst pred)
  8. (fold (λ (current-elem accumulated)
  9. (or (pred current-elem)
  10. accumulated))
  11. #f
  12. lst)))
  13. (define all-pred?
  14. (λ (lst pred)
  15. (fold (λ (current-elem accumulated)
  16. (and (pred current-elem)
  17. accumulated))
  18. #t
  19. lst)))