(define (make-ring n)
  (define (make-list n result)
    (if (= n 0)
        (cons 0 result)
        (make-list (-1+ n) (cons n result))))
  (let* ((last-cel (list (-1+ n)))
         (first-cel (make-list (- n 2) last-cel)))
    (set-cdr! last-cel first-cel)))
(define (show-ring r)
  (display (car r))
  (display " ")
  (show-ring (cdr r)))
(define (rotate-left r)
  (cdr r))
(define (rotate-right r)
  (define (loop-until-cdr-eq? lst cdrmustbe)
    (if (eq? (cdr lst) cdrmustbe)
        lst
        (loop-until-cdr-eq? (cdr lst) cdrmustbe)))
  (loop-until-cdr-eq? r r))
(define (show-ring-rev r)
  (display (car r))
  (display " ")
  (show-ring-rev (rotate-right r)))