home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 213a.lha / Scheme / HOP.scm < prev    next >
Text File  |  1996-02-14  |  515b  |  31 lines

  1. ;;; HOP.scm
  2.  
  3. ;;;
  4. ;;; Useful Higher-Order Procedures
  5. ;;;
  6.  
  7. (define (filter predicate source-list)
  8.   (cond ((null? source-list) '())
  9.     ((predicate (car source-list))
  10.      (cons (car source-list)
  11.            (filter predicate (cdr source-list)) ))
  12.     (else
  13.      (filter predicate (cdr source-list)) )))
  14.  
  15. (define (repeat thunk n)
  16.   (if (< n 1)
  17.       #u
  18.       (begin
  19.     (thunk)
  20.     (repeat thunk (- n 1)) )))
  21.  
  22. (define (repeated f n)
  23.   (if (< n 1)
  24.       (lambda (x) x)
  25.       (lambda (x) ((repeated f (- n 1)) (f x))) ))
  26.  
  27.  
  28.  
  29. ;;; EOF HOP.scm
  30.  
  31.