Symbol class: Conses, Lists and related functions

Syntax:

Symbol type: macro

Argument description:

item | an object |

place | a place which can contain any object, but usually list |

key | function for extracting value before test |

test | function key and item comparison |

PUSHNEW macro modifies variable or generally place. It conditionally makes a new cons cell filled with item as car and previous value as cdr, that is effectively prepends new item to list found at the place. New element is pushed only when it does not appear in place. Test argument specifies comparison operator. Default comparison operator is EQL. Key argument specifies function for extracting relevant value from list items. Default key is IDENTITY. See also PUSH-NEW, ACONS and POP.

(let ((x 'x)) (pushnew 4 x) x) => (4 . X) (let ((x '(3 2 1))) (pushnew 4 x) x) => (4 3 2 1) (let ((x '(3 2 1))) (pushnew 3 x) x) => (3 2 1) (let ((x '((a b c) (3 2 1) (e f g)))) (pushnew 4 (second x)) x) => ((A B C) (4 3 2 1) (E F G)) (let ((x '((a b c) (3 2 1) (e f g)))) (pushnew 3 (second x)) x) => ((A B C) (3 2 1) (E F G)) (let ((x '("3" "2" "1"))) (pushnew "3" x) x) => (3 2 1) (let ((x '("31" "24" "13"))) (pushnew "44" x :key (lambda (x) (elt x 0))) x) => ("44" "31" "24" "13") (let ((x '("31" "24" "13"))) (pushnew "44" x :key (lambda (x) (elt x 1))) x) => ("31" "24" "13")