Re: How to define the append function to add an element into a given list
- From: fortunatus <daniel.eliason@xxxxxxxxxx>
- Date: Thu, 23 Jul 2009 10:18:16 -0700 (PDT)
On Jul 23, 10:54 am, bj...@xxxxxxx (Björn Lindberg) wrote:
The simplest possible queue implementation is a cons cell where car
and cdr points to the first and last cons cell of a list respectively.
Björn Lindberg
You might as well use a structure or class, and face the fact that you
will be doing quite a bit of code to handle going from empty to one
item to two items, and from two to one to empty.
In other words, this is going to be *classic* linked list work that is
not really facilitated by Lisp - gonna be about the same as with C or
assembly.
The easiest, Lispiest way I know is
(defun append-item (queue item) (append queue `(,item)))
But terribly inefficient unless I don't understand something about
implementations.
.
- Follow-Ups:
- Re: How to define the append function to add an element into a given list
- From: Raffael Cavallaro
- Re: How to define the append function to add an element into a given list
- References:
- How to define the append function to add an element into a given list
- From: Elvis Nguyen
- Re: How to define the append function to add an element into a given list
- From: Elvis Nguyen
- Re: How to define the append function to add an element into a given list
- From: Kyle M
- Re: How to define the append function to add an element into a given list
- From: Björn Lindberg
- How to define the append function to add an element into a given list
- Prev by Date: Re: O'Reilly is publishing a book on Common Lisp
- Next by Date: ∴★∵**☆ DISCOUNT!!! Sale of cheap brand shoes,T-shirt, earings,handbags.(www.ecyoyo.com)
- Previous by thread: Re: How to define the append function to add an element into a given list
- Next by thread: Re: How to define the append function to add an element into a given list
- Index(es):
Relevant Pages
|