This only triggers with the (not captured) test removed: (define (foo x y) (define (any pred lst) (let loop ((lst lst)) (cond ((null? lst) #f) ((pred (car lst))) (else (loop (cdr lst)))))) (define (append-map proc lst1 . lsts) (if (null? lsts) (foldr (lambda (x r) (append (proc x) r)) '() lst1) (let loop ((lsts (cons lst1 lsts))) (if (any null? lsts) '() (append (apply proc (map (lambda (x) (car x)) lsts)) (loop (map (lambda (x) (cdr x)) lsts))))))) (append-map (lambda (a b) (print a b)) x y))