(define (iota m n)
  (if (> m n)
     (cons m (iota (+ m 1) n))))

(define list-copy (lambda (l)
  (append l '())))

;;;  note the reverses
;;;  AFAIK, guile doesn't have a primitive for grabbing elts from the
;;;  end of a list.  no scheme programmer would do this anyway.  they'd
;;;  reverse the list in place
(define (test-lists SIZE)
 (let* ((Li1 (cdr (iota 0 SIZE)))
       (Li2 (list-copy Li1))
       (Li3 '()))
    (do ((elt (car Li2) (car Li2)))
	((eq? (cdr Li2) '()) (begin  (set! Li3 (cons elt Li3))
				     (set! Li2 '())
				     (set! Li3 (reverse! Li3))))
      (begin (set! Li3 (cons elt Li3))
	     (set! Li2 (cdr Li2))))

    (set! Li3 (reverse! Li3))
    (do ((elt (car Li3) (car Li3)))
	((eq? (cdr Li3) '()) (begin (set! Li2 (cons elt Li2))
				    (set! Li3 '())
				    (set! Li2 (reverse! Li2))))
      (begin (set! Li2 (cons elt Li2))
	     (set! Li3 (cdr Li3))))
    (set! Li1 (reverse! Li1))

    (if (and (= (car Li1) SIZE) (every-2? = Li1 Li2)) (length Li1) 0))))
(define every-2? (lambda (test l1 l2)
  (or (null? l1)
      (and (test (car l1) (car l2))
           (every-2? test (cdr l1) (cdr l2))))))

(define (main args)
  (let ((n (or (and (= (length args) 1) (string->number (car args))) 1)))
    (begin (display (test-lists n)) (newline))))

Generated by GNU enscript 1.6.3.