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


36.5 Mapping over 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-map-left dst-stack fun src-stack
Function: $stack-map-left dst-stack fun src-stack

Iterate over all the objects in src-stack, starting from the top side, apply fun to them, push the result of the application in the bottom side of dst-stack.

(stack->list
  (stack-map-left (stack) - (stack 0 1 2 3)))
⇒ (0 -1 -2 -3)

The dst-stack argument allows us to build the destination stack with the desired configuration parameters.

Function: stack-map-right dst-stack fun src-stack
Function: $stack-map-right dst-stack fun src-stack

Iterate over all the objects in src-stack, starting from the bottom side, apply fun to them, push the result of the application in the top side of dst-stack.

(stack->list
  (stack-map-right (stack) - (stack 0 1 2 3)))
⇒ (0 -1 -2 -3)

The dst-stack argument allows us to build the destination stack with the desired configuration parameters.

Function: stack-map fun stack
Function: $stack-map fun stack

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

Function: stack-for-each-left fun stack
Function: $stack-for-each-left fun stack

Iterate over all the objects in stack, starting from the top side, and apply fun to them discarding the return value.

Function: stack-for-each-right fun stack
Function: $stack-for-each-right fun stack

Iterate over all the objects in stack, starting from the bottom side, and apply fun to them discarding the return value.

Function: stack-for-each fun stack
Function: $stack-for-each fun stack

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


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