The stack data type provides a simple LIFO stack. There are two implementations of a stack in Elib, one using macros and one using functions. The names of the functions/macros in the two implementations are the same, but the efficiency of using one or the other vary greatly under different circumstances.
The implementation using macros should be used when you want to
byte-compile your own elisp program. This will be most efficient since
byte-compiling an elisp function using macros has the same effect as
using inline code in C
.
To use the stack data type, put the line
(require 'stack-f)
in your own elisp source file if you want to use the implementation using functions or
(require 'stack-m)
if you want to use the implementation using macros. This is the only difference between them, so it is easy to switch between them during debugging.
The following functions are provided by the stack:
(stack-create)
(stack-p stack)
t
if stack is a stack, otherwise return nil
.
(stack-push stack element)
(stack-pop stack)
nil
.
(stack-empty stack)
t
if stack is empty, otherwise return nil
.
(stack-top stack)
nil
if stack is empty.
(stack-nth stack n)
nil
. The
element is not removed from the stack.
(stack-all stack)
(stack-copy stack)
(stack-length stack)
(stack-clear stack)
Go to the first, previous, next, last section, table of contents.