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


36.7 Filtering in stacks

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

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

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

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

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

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

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