From ... From: Erik Naggum Subject: Re: how to append an item to a list ? Date: 2000/01/20 Message-ID: <3157378406727027@naggum.no>#1/1 X-Deja-AN: 575375293 References: <38856415.434303225@news.vtc.ru> <38865ac1.7536977@news.vtc.ru> mail-copies-to: never Content-Type: text/plain; charset=us-ascii X-Complaints-To: newsmaster@eunet.no X-Trace: oslo-nntp.eunet.no 948394858 17504 195.0.192.66 (20 Jan 2000 19:00:58 GMT) Organization: Naggum Software; +47 8800 8879 or +1 510 435 8604; fax: +47 2210 9077; http://www.naggum.no User-Agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.5 Mime-Version: 1.0 NNTP-Posting-Date: 20 Jan 2000 19:00:58 GMT Newsgroups: comp.lang.lisp * Arseny Slobodjuck | Actually i need something like push, but unlike push it have to insert | new item to the end of list. if you don't need a list, consider VECTOR-PUSH. | So, i need an equivalent to | | (setq a (concatenate 'list a (list b))) (append a (list b)) | (rplacd (last a) (list b)) (setf (setf tail (cdr tail)) (cons b nil)) is better, once you keep two variables to point into the list: (setf tail (cons nil nil)) (setf head (cdr tail)) you might want to do this in a structure or class to capture it in a unit, but most of the time, you can use this technique in a short piece of code without the overhead of extra datatypes and their accessors. however, the most common way to do this is to collect the items in a list in reverse, and then reverse the list (destructively, with NREVERSE). this won't work if you need access to the list elements along the way, in which case only the HEAD/TAIL approach outlined above will do. #:Erik