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

push


Type:   -   Lisp macro
Source:   -   misc.lsp

Syntax

(push expr list)
expr - an expression
list - a list
returns - the new value of list

'push' is implemented as a Lisp macro:

(defmacro push (val lis)
  `(setf ,lis (cons ,val ,lis)))

Description

The 'push' macro stores the value of the expression to the front of the list and returns the list.

Examples

(setq lst nil)  => NIL
(push 1 lst)    => (1)
lst             => (1)
(push 2 lst)    => (2 1)
lst             => (2 1)
(push 3 lst)    => (3 2 1)
lst             => (3 2 1)

See setq. See also the pop macro.

  Back to Top


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