chickadee » stack

stack

Documentation

The stack extension is a set of procedures and macros supporting LIFO queue operations.

make-stack

make-stackprocedure

Returns a new stack object.

list->stack

list->stack LISTprocedure

Returns a new stack object with initial elements from the LIST.

The stack order is as (apply stack-push! STACK (reverse LIST)). In other words LIST should be in the desired LIFO order, (TOS ... BOS).

stack?

stack? OBJECTprocedure

Is OBJECT a stack?

stack-empty?

stack-empty? STACKprocedure

Returns #t for an empty stack, #f otherwise.

stack-count

stack-count STACKprocedure

Returns the count of elements on the stack.

stack-empty!

stack-empty! STACKprocedure

Make stack empty.

stack-peek

stack-peek STACK #!optional INDEXprocedure

Returns the element in stack at INDEX.

INDEX must be in [0 (stack-count) - 1]. INDEX defaults to 0.

stack-poke!

stack-poke! STACK OBJECT #!optional INDEXprocedure

Changes the stack element at INDEX to OBJECT.

INDEX must be in [0 (stack-count) - 1]. INDEX defaults to 0.

The stack is modified in place.

stack-push!

stack-push! STACK OBJECT ...procedure

Pushes OBJECT ... onto the stack.

The stack is modified in place.

stack-pop!

stack-pop! STACKprocedure

Removes the top element from the stack and returns it.

The stack is modified in place.

stack-cut!

stack-cut! STACK START #!optional ENDprocedure

Removes the stack elements from the indexes START upto END and returns a list of the stack elements.

The START must be in [0 (stack-count) - 1].

The END must be in [START (stack-count)]. END defaults to (stack-count).

The stack is modified in place.

stack->list

stack->list STACKprocedure

Returns the stack as a new list, where the first element of the list is the top element of the stack.

stack-fold

stack-fold STACK PROCEDURE INITIALprocedure

Invokes the PROCEDURE on each element of the stack and the accumulated result. Returns the accumulated result. The initial accumulated result is INITIAL.

Processing of the stack elements in order of top to bottom.

stack-for-each

stack-for-each STACK PROCEDUREprocedure

Invokes the PROCEDURE on each element of the stack.

Processing of the stack elements in order of top to bottom.

stack-map

stack-map STACK PROCEDUREprocedure

Invokes the PROCEDURE on each element of the stack, collecting in a result LIST.

Processing of the stack elements in order of top to bottom.

Usage

(import stack)

Requirements

record-variants check-errors

test test-utils

Author

Kon Lovett

Repository

This egg is hosted on the CHICKEN Subversion repository:

https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/stack

If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.

Version history

3.1.0
Newer dependency (smaller binary).
3.0.11
.
3.0.10
.
3.0.9
.
3.0.8
Query & access routines are pure.
3.0.7
.
3.0.6
Fix stack printing.
3.0.5
Export stack-fold.
3.0.4
Use -strict-types.
3.0.3
.
3.0.2
.
3.0.1
Fix category.
3.0.0
CHICKEN 5 release.

License

Copyright (C) 2009-2023 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.

Contents »