Function: ring-ref

ring-ref is a byte-compiled function defined in ring.el.gz.

Signature

(ring-ref RING INDEX)

Documentation

Return RING's INDEX element.

INDEX = 0 is the most recently inserted; higher indices correspond to older elements. INDEX need not be <= the ring length; the appropriate modulo operation will be performed.

View in manual

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/ring.el.gz
(defun ring-ref (ring index)
  "Return RING's INDEX element.
INDEX = 0 is the most recently inserted; higher indices
correspond to older elements.
INDEX need not be <= the ring length; the appropriate modulo operation
will be performed."
  (if (ring-empty-p ring)
      (error "Accessing an empty ring")
    (let ((hd (car ring))
	  (ln (cadr ring))
	  (vec (cddr ring)))
      (aref vec (ring-index index hd ln (length vec))))))