list-procs.scm 669 B

123456789101112131415161718192021222324252627282930
  1. (library (list-procs)
  2. (export recursive-member
  3. rest)
  4. (import (rnrs base)
  5. (only (guile)
  6. lambda* λ)
  7. ;; GNU Guile batteries
  8. (ice-9 exceptions)
  9. ;; SRFIs
  10. ;; SRFI 1 - list procs
  11. (srfi srfi-1)))
  12. (define rest
  13. (λ (lst)
  14. (cdr lst)))
  15. (define recursive-member
  16. (λ (seeked lst test-proc)
  17. (cond
  18. [(null? lst) #f]
  19. [(pair? (first lst))
  20. (or (recursive-member seeked (first lst) test-proc)
  21. (recursive-member seeked (rest lst) test-proc))]
  22. [(test-proc (first lst) seeked)
  23. lst]
  24. [else
  25. (recursive-member seeked (rest lst) test-proc)])))