[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FOR-EACH is missing from the reference implementation of SRFI 1

The reference implementation is missing a definition of FOR-EACH as
specified in the document.  Here is one.  (I've tried, as best as I
could, to imitate Olin's style.)

(define (for-each f lis1 . lists)
  (check-arg procedure? f for-each)
  (if (pair? lists)
      (let recur ((lists (cons lis1 lists)))
	(receive (cars cdrs) (%cars+cdrs lists)
	  (if (pair? cars)
		(apply f cars)		; Do head first,
		(recur cdrs)))))	; then tail.
      ;; Fast path.
      (let recur ((lis lis1))
	(if (not (null-list? lis))
	      (f (car lis))		; Do head first,
	      (recur (cdr lis)))))))	; then tail.

Olin, if you're there---I'd be happy to put this in the reference
implementation of srfi.schemers.org if and when I have your OK.

Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla