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

46.3 Immutable lists as stacks

The library (vicare containers istacks ilists) provides a concrete implementation of the <istack> type using immutable lists as storage; immutable lists are defined by the library (vicare containers ilists), Immutable lists. Usage example:

(import (vicare)
  (vicare containers istacks)
  (vicare containers istacks ilists))

(define S

(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 ilists).

Record Type: <istack-ilist>

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

Function: make-istack-ilist
Function: make-istack-ilist ell

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

Function: istack-ilist? obj

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

Function: istack-ilist-first-pair istack

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