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


36.6 Searching 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-for-all fun stack
Function: $stack-for-all fun stack

Apply the procedure fun over the objects in stack, starting from the top side; stop at the first application returning #f and return #f. If the iteration reaches the end of the stack: the return value is the result of applying fun to the last object in the stack. If the stack is empty: the return value is #t.

Function: stack-exists-left fun stack
Function: $stack-exists-left fun stack

Apply the procedure fun over the objects in stack, starting from the top side; stop at the first application returning true and return the returned value. If the stack is empty: the return value is #f.

Function: stack-exists-right fun stack
Function: $stack-exists-right fun stack

Apply the procedure fun over the objects in stack, starting from the bottom side; stop at the first application returning true and return the returned value. If the stack is empty: the return value is #f.

Function: stack-exists fun stack
Function: $stack-exists fun stack

Aliases for stack-exists-left and $stack-exists-left.

Function: stack-find-left fun stack
Function: stack-find-left fun stack not-found-rv
Function: $stack-find-left fun stack not-found-rv

Apply the procedure fun to the objects in stack, starting from the top side: stop at the first true value and return the object from stack that generated it.

When not-found-rv is not used: if all the applications return #f, the return value is #f.

When not-found-rv is used: if all the applications return #f, the return value is not-found-rv.

(stack-find-left
    even?
  (stack 1 3 5 7)
  'not-found)
⇒ not-found

(stack-find-left
    even?
  (stack 1 3 5 7))
⇒ #f

(stack-find-left
    even?
  (stack 1 3 5 6 7)
  'not-found)
⇒ 6
Function: stack-find-right fun stack
Function: stack-find-right fun stack not-found-rv
Function: $stack-find-right fun stack not-found-rv

Apply the procedure fun to the objects in stack, starting from the bottom side: stop at the first true value and return the object from stack that generated it.

When not-found-rv is not used: if all the applications return #f, the return value is #f.

When not-found-rv is used: if all the applications return #f, the return value is not-found-rv.

Function: stack-find fun stack
Function: stack-find fun stack not-found-rv
Function: $stack-find fun stack not-found-rv

Aliases for stack-find-left and $stack-find-left.


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