All Manuals > LispWorks® User Guide and Reference Manual > 37 The HCL Package

ring-pop Function

Summary

Removes an element from a ring and returns the element before the insertion point.

Package

hcl

Signature

ring-pop ring &optional remove => object

Arguments
ring
A ring object created by make-ring.
remove
A generalized boolean.
Values
object
A Lisp object.
Description

The function ring-pop removes (by default) an element from ring and returns the element before the insertion point.

If remove is true then the element is removed from ring. If remove is nil then the element remains and instead ring is rotated by 1 as if by (rotate-ring ring 1). The default value of remove is t.

ring-pop signals an error when called on an empty ring.

Examples

These 3 forms all return the same values, but the first form removes an element from a ring, while the other two leave all the elements in the ring:

(values (ring-pop ring) (ring-ref ring 0))
(values (ring-pop ring t) (ring-ref ring 0))
(values (ring-ref ring 0) (rotate-ring ring 1))
See also

ring-push
make-ring
rotate-ring
ring-ref
ring-length


LispWorks® User Guide and Reference Manual - 01 Dec 2021 19:30:35