stack

  1. stack
  2. Documentation
    1. make-stack
    2. list->stack
    3. stack?
      1. check-stack
      2. error-stack
    4. stack-empty?
    5. stack-count
    6. stack-empty!
    7. stack-peek
    8. stack-poke!
    9. stack-push!
    10. stack-pop!
    11. stack-cut!
    12. stack->list
    13. stack-fold
    14. stack-for-each
    15. stack-map
  3. Usage
  4. Requirements
  5. Author
  6. Repository
  7. Version history
  8. License

Documentation

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

make-stack

[procedure] (make-stack) -> stack

Returns a new stack object.

list->stack

[procedure] (list->stack LIST) -> stack

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?

[procedure] (stack? OBJECT) -> boolean

Is OBJECT a stack?

check-stack
[procedure] (check-stack LOC OBJ [ARGNAM]) -> stack
error-stack
[procedure] (error-stack LOC OBJ [ARGNAM])

stack-empty?

[procedure] (stack-empty? STACK) -> boolean

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

stack-count

[procedure] (stack-count STACK) -> fixnum

Returns the count of elements on the stack.

stack-empty!

[procedure] (stack-empty! STACK)

Make stack empty.

stack-peek

[procedure] (stack-peek STACK [INDEX]) -> *

Returns the element in stack at INDEX.

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

stack-poke!

[procedure] (stack-poke! STACK OBJECT [INDEX])

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!

[procedure] (stack-push! STACK OBJECT ...)

Pushes OBJECT ... onto the stack.

The stack is modified in place.

stack-pop!

[procedure] (stack-pop! STACK) -> *

Removes the top element from the stack and returns it.

The stack is modified in place.

stack-cut!

[procedure] (stack-cut! STACK START [END]) -> list

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

[procedure] (stack->list STACK) -> list

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

stack-fold

[procedure] (stack-fold STACK PROCEDURE INITIAL) -> *

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

[procedure] (stack-for-each STACK PROCEDURE)

Invokes the PROCEDURE on each element of the stack.

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

stack-map

[procedure] (stack-map STACK PROCEDURE) -> list

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.2.0
Add check-stack & error-stack.
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-2024 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.