(define append
  (lambda (ls1 ls2)
    (if (null? ls1)
	ls2
	(cons (car ls1)
	      (append (cdr ls1) ls2)))))

(define append!
  (lambda (ls1 ls2)
    (letrec
      ((last-pair
	(lambda (ls)
	  (if (null? (cdr ls))
	      ls
	      (last-pair (cdr ls))))))
      (set-cdr! (last-pair ls1) ls2))))

(define circular?
  (lambda (s)
    (letrec
      ((loop
	(lambda (t)
	  (if (pair? t)
	      (or (eq? s t) (loop (cdr t)))
	      #f))))
      (if (pair? s)
          (loop (cdr s))
	  #f))))