source: project/wiki/eggref/4/stack @ 13526

Last change on this file since 13526 was 13526, checked in by Kon Lovett, 11 years ago

Rmvd keyword arg style from 'box'. Save for 'stack'.

File size: 4.2 KB
Line 
1[[tags: egg]]
2
3== stack
4
5[[toc:]]
6
7
8== Documentation
9
10The '''stack''' extension is a set of procedures and macros supporting LIFO
11queue operations.
12
13=== make-stack
14
15<procedure>(make-stack) => STACK</procedure>
16
17Returns a new {{STACK}} object.
18
19=== list->stack
20
21<procedure>(list->stack LIST) => STACK</procedure>
22
23Returns a new {{STACK}} object with initial elements from the {{LIST}}.
24
25=== stack?
26
27<procedure>(stack? OBJECT) => BOOLEAN</procedure>
28
29Is {{OBJECT}} a stack?
30
31=== stack-empty?
32
33<procedure>(stack-empty? STACK) => BOOLEAN</procedure>
34
35Returns #t for an empty {{STACK}}, #f otherwise.
36
37=== stack-count
38
39<procedure>(stack-count STACK) => NUMBER</procedure>
40
41Returns the count of elements on the {{STACK}}.
42
43=== stack-empty!
44
45<procedure>(stack-empty! STACK) => UNSPECIFIED</procedure>
46
47Make {{STACK}} empty.
48
49=== stack-peek
50
51<procedure>(stack-peek STACK [INDEX]) => OBJECT</procedure>
52
53Returns the element in {{STACK}} at {{INDEX}}.
54
55{{INDEX}} must be in [0 {{(stack-count) - 1}}]. {{INDEX}} defaults to 0.
56
57=== stack-poke!
58
59<procedure>(stack-poke! STACK OBJECT [INDEX]) => UNSPECIFIED</procedure>
60
61Changes the {{STACK}} element at {{INDEX}} to {{OBJECT}}.
62
63{{INDEX}} must be in [0 {{(stack-count) - 1}}]. {{INDEX}} defaults to 0.
64
65The stack is modified in place.
66
67=== stack-push!
68
69<procedure>(stack-push! STACK OBJECT ...) => UNSPECIFIED</procedure>
70
71Pushes {{OBJECT ...}} onto the {{STACK}}.
72
73The stack is modified in place.
74
75=== stack-pop!
76
77<procedure>(stack-pop! STACK) => OBJECT</procedure>
78
79Removes the top element from the {{STACK}} and returns it.
80
81The stack is modified in place.
82
83=== stack-cut!
84
85<procedure>(stack-cut! STACK START [END]) => LIST</procedure>
86
87Removes the {{STACK}} elements from the indexes {{START}} upto {{END}} and
88returns a list of the stack elements.
89
90The {{START}} must be in [0 {{(stack-count) - 1}}].
91
92The {{END}} must be in [{{START}} {{(stack-count)}}]. {{END}} defaults to
93{{(stack-count)}}.
94
95The stack is modified in place.
96
97=== stack->list
98
99<procedure>(stack->list STACK) => LIST</procedure>
100
101Returns the {{STACK}} as a new list, where the first element of the list is the
102top element of the stack.
103
104=== stack-fold
105
106<procedure>(stack-fold STACK PROCEDURE INITIAL) => OBJECT</procedure>
107
108Invokes the {{PROCEDURE}} on each element of the {{STACK}} and the accumulated
109result. Returns the accumulated result. The initial accumulated result is
110{{INITIAL}}.
111
112Processing of the {{STACK}} elements in order of top to bottom.
113
114=== stack-for-each
115
116<procedure>(stack-for-each STACK PROCEDURE) => UNSPECIFIED</procedure>
117
118Invokes the {{PROCEDURE}} on each element of the {{STACK}}.
119
120Processing of the {{STACK}} elements in order of top to bottom.
121
122=== stack-map
123
124<procedure>(stack-map STACK PROCEDURE) => LIST</procedure>
125
126Invokes the {{PROCEDURE}} on each element of the {{STACK}}, collecting in a
127result {{LIST}}.
128
129Processing of the {{STACK}} elements in order of top to bottom.
130
131
132== Usage
133
134<enscript language=scheme>
135(require-extension stack)
136(import stack)
137</enscript>
138
139
140== Examples
141
142
143== Notes
144
145
146== Requirements
147
148
149== Bugs and Limitations
150
151
152== Author
153
154[[kon lovett]]
155
156
157== Version history
158
159; 2.0.0 : Port to hygienic Chicken.
160
161
162== License
163
164Copyright (C) 2009 Kon Lovett.  All rights reserved.
165
166Permission is hereby granted, free of charge, to any person obtaining a copy of
167this software and associated documentation files (the Software), to deal in the
168Software without restriction, including without limitation the rights to use,
169copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
170Software, and to permit persons to whom the Software is furnished to do so,
171subject to the following conditions:
172
173The above copyright notice and this permission notice shall be included in all
174copies or substantial portions of the Software.
175
176THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
177IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
178FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
179AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
180LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
181OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
182SOFTWARE.
Note: See TracBrowser for help on using the repository browser.