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


46.4 Random–access lists as stacks

The library (vicare containers istacks ralists) provides a concrete implementation of the <istack> type using random–access lists as storage; random–access lists are defined by the library (vicare containers ralists), Random–access lists. Usage example:

(import (vicare)
  (vicare containers istacks)
  (vicare containers istacks ralists))

(define S
  (make-istack-ralist))

(istack-push! S 0)
(istack-push! S 1)
(istack-push! S 2)

(istack-top  S)         ⇒ 2
(istack-pop! S)         ⇒ 2
(istack-pop! S)         ⇒ 1

The following syntactic bindings are exported by the library (vicare containers istacks ralists).

Record Type: <istack-ralist>

Record type implementing an <istack>, of which it is a subtype.

Function: make-istack-ralist
Function: make-istack-ralist ell

Build and return a new instance of <istack-ralist>. The optional argument ell must be a proper random–access list (or null) representing the initial contents of the stack, with the car of the list being the top object.

Function: istack-ralist? obj

Return #t if obj is an instance of <istack-ralist>; otherwise return #f.

Function: istack-ralist-first-pair istack

Return null or the first pair of the list used as storage in the <istack-ralist> instance istack.