chickadee » stack

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

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.

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

(require-extension stack)

or

(require-library stack)
...
(import stack)

Examples

Notes

Requirements

setup-helper check-errors

Bugs and Limitations

Author

Kon Lovett

Version history

2.3.0
Drop typed-modules.
2.2.1
Fix type.
2.2.0
Uses typed-modules egg. Slightly faster.
2.1.4
Fix for ticket #630.
2.1.3
2.1.2
2.1.1
2.1.0
2.0.0
Port to hygienic Chicken.

License

Copyright (C) 2009-2017 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 »