et for-eachn ((rest rest))
         (or (null? rest)
             (if (= (length (car rest)) len)
                 (for-eachn (cdr rest))
                 (scm-error 'wrong-type-arg "for-each" "List of wrong length: ~S"
                            (list (car rest)) #f)))))

     (let for-eachn ((l1 l1) (rest rest))
       (if (pair? l1)
           (begin
             (apply f (car l1) (map car rest))
             (for-eachn (cdr l1) (map cdr rest))))))))


;; Temporary definitions used by `include'; replaced later.

(define (absolute-file-name? file-name) #t)
(define (open-input-file str) (open-file str "r"))

;; Temporary definition; replaced by a parameter later.
(define (allow-legacy-syntax-objects?) #f)

;;; {and-map and or-map}
;;;
;;; (and-map fn lst) is like (and (fn (car lst)) (fn (cadr lst)) (fn...) ...)
;;; (or-map fn lst) is like (or (fn (car lst)) (fn (cadr lst)) (fn...) ...)
;;;

(define (and-map f lst)
  "Apply F to successive elements of LST until exhaustion or F returns #f.
If returning early, return #f.  Otherwise, return the last value returned
by F.  If F has never been called because LST is empty, return #t."
  (let loop ((result #t)
             (l lst))
    (and result
         (or (and (null? l)
                  result)
             (loop (f (car l)) (cdr l))))))

(define (or-map f lst)
  "Apply F to successive elements of LST until exhaustion or while F returns #f.
If returning early, return the return value of F."
  (let loop ((result #f)
             (l lst))
    (or result
        (and (not (null? l))
             (loop (f (car l)) (cdr l))))))

