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


37.9 Queue iteration thunks

Iteration thunks are procedures accepting no arguments and returning an item from a collection; when the iteration finishes: the return value is the void object. Iteration thunks can be used with the facilities of the library (vicare containers iteration-thunks) (see iteration thunks). The following syntactic bindings are exported by the library (vicare containers queues).

Function: make-queue-iteration-thunk queue

Build and return a new iteration thunk popping the objects from queue.

(import (vicare)
  (vicare containers queues)
  (vicare containers iteration-thunks))

(define (xcons a b)
  (cons b a))

(iteration-thunk-fold
    xcons
  '()
  (make-queue-iteration-thunks (queue)))
⇒ ()

(iteration-thunk-fold
    xcons
  '()
  (make-queue-iteration-thunks (queue 0 1 2 3 4 5)))
⇒ (5 4 3 2 1 0)