std-pushmax | ![]() |
STD-PUSHMAX
works like STD-PUSH
, except that it keeps the stack to a maximal length of nmax. If the stack exceed nmax the last element is removed from the stack making room for the new element.
The stack may be defined as list or as symbol (a quoted list) which means that the value of the symbol is set to the return value ("destructive").
(std-pushmax 0 '(1 2 3 4) 4) => (0 1 2 3) (setq stack '(1 2 3)) (std-push 0 'stack 4) => (0 1 2 3) !stack => (0 1 2 3) (std-push 1 'stack 4) => (1 0 1 2)
x: any valid lisp expression
lst: a list or a quoted symbol, which evaluates to a list.
nmax: a positive integer number
A list.
This function may be called only because of its side effect.
It may change the value of the second argument, if it is a symbol.
(std-require 'STDLIST)
Defined in STDLIST