Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference

pop


Type:   -   Lisp macro
Source:   -   misc.lsp

Syntax

(pop list)
list - a list
returns - the first element from the list

'pop' is implemented as a Lisp macro:

(defmacro pop (lis)
  `(prog1 (car ,lis)
          (setf ,lis (cdr ,lis))))

Description

The 'pop' macro reads, removes and returns the first element from the list.

Examples

(setq stack '(a b c))  => (A B C)
(pop stack)            => A  
stack                  => (B C)
(pop stack)            => B  
stack                  => (C)
(pop stack)            => C 
stack                  => NIL
(pop stack)            => NIL
stack                  => NIL

See setq. See also the push macro.

  Back to Top


Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference