Function: ring-convert-sequence-to-ring

ring-convert-sequence-to-ring is a byte-compiled function defined in ring.el.gz.

Signature

(ring-convert-sequence-to-ring SEQ)

Documentation

Convert sequence SEQ to a ring, and return the ring.

If SEQ is already a ring, return it. Members of SEQ that are equal to the first member are not inserted, which will cause the resulting ring to have nil elements.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/ring.el.gz
(defun ring-convert-sequence-to-ring (seq)
  "Convert sequence SEQ to a ring, and return the ring.
If SEQ is already a ring, return it.
Members of SEQ that are `equal' to the first member are not inserted,
which will cause the resulting ring to have nil elements."
  (if (ring-p seq)
      seq
    (let* ((size (length seq))
           (ring (make-ring size)))
      (dotimes (count size)
        (when (or (ring-empty-p ring)
		  (not (equal (ring-ref ring 0) (elt seq count))))
	  (ring-insert-at-beginning ring (elt seq count))))
      ring)))