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


37.7 Filtering in queues

The following syntactic bindings are exported by the library (vicare containers queues). The syntactic bindings whose name is prefixed with $ are unsafe operations: they do not validate their arguments before accessing them.

Function: queue-filter dst-queue pred src-queue
Function: $queue-filter dst-queue pred src-queue

Iterate over the objects in src-queue starting from the front side, apply pred to them, push on the rear of dst-queue the ones for which pred returns true. Return dst-queue itself.

The argument dst-queue allows us to build and configure a queue with the needed parameters.

Function: queue-partition match-queue no-match-queue pred src-queue
Function: $queue-partition match-queue no-match-queue pred src-queue

Iterate over the objects in src-queue, starting from the front side, and apply pred to them: if the return value is true, push the object on the rear of match-queue; if the return value is #f, push the object on the rear of no-match-queue. Return two values: match-queue and no-match-queue.

The arguments match-queue and no-match-queue allow us to build and configure queues with the needed parameters.