Provides LIFO queue (stack) operations.
stack is a set of procedures and macros supporting LIFO queue operations. The stack is treated as an independent object, which is modified in place. In opposition to the common pattern of a variable being re-assinged a new stack representation after each mutating operation.
Returns a new stack, with optional initial elements from LIST.
Make STACK empty.
Is STACK a stack?
Returns #t for an empty STACK, #f otherwise.
Returns the number of elements on the STACK.
Returns the index of the last element on the STACK, or -1 when stack empty.
Returns the element in STACK at INDEX. Index must be 0 <= & <= (stack-depth), defaults to 0 (top of stack).
Changes the STACK element at INDEX to VALUE. Returns the modified stack. The stack is modified in place. Index must be 0 <= & <= (stack-depth), defaults to 0 (top of stack).
Pushes VALUE ... onto the STACK. Returns the modified stack. The stack is modified in place.
Removes the top element from the STACK and returns it. The stack is modified in place. Does not check for the stack-empty condition!
Removes the top element from the STACK and returns it. The stack is modified in place.
Removes the STACK elements from START-DEPTH thru END-DEPTH and returns a list of the stack elements. The stack is modified in place. The start-depth must be 0 <= & <= (stack-depth). The end-depth must be start-depth <= & <= (stack-depth), defaults to start-depth.
Returns the LIST as a stack. The resulting stack may share memory with the list and the list should not be modified after this operation.
Returns the STACK as a list, where the first element of the list is the top element of the stack. The resulting list may share memory with the stack object and should not be modified.
Applies the PROCEDURE to each element of the STACK, in order of top to bottom.
Prints the elements of the STACK to the (current-output-port)
.
Copyright (c) 2005, Kon Lovett. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.