Next: , Previous: , Up: lists   [Index]


23.14 Circular lists

Constructors

Function: circular-list obj1 obj2 ...
Syntax: circular-list/stx obj1 obj2 ...

Construct a circular list (a ring) of the elements.

(circular-list 'z 'q)
⇒ (z q z q z q ...)
Function: list->circular-list! ell
Syntax: list->circular-list!/stx ell

Take a proper list and make it circular (a ring). Return the circular list.

Function: circular-list->list! circ
Function: circular-list->list!/stx circ

Take a circular list and “open it” returning a proper list. The car of the returned list is the car of circ. If circ is null, return null.

Function: circular-list-copy circ
Syntax: circular-list-copy/stx circ

Build and return a copy of circ. If circ is null, return null.

Inspection

Function: circular-list-length circ
Syntax: circular-list-length/stx circ

Return the number of elements in circ. The length of a circular list is a non–negative exact integer N such that: cdr applied N times to circ, returns the circ pair itself.

Comparison

Function: circular-list= item= clist ...
Function: circular-list=/stx item= clist1 clist2

Compare the list arguments using item=, return true if the lists are equal. If all the list arguments are null, return #t. If at least one list arguments is null, but not all, return #f. If the list arguments have different length, return #f.