Re: Idiomatic lisp - loops
- From: "Tayssir John Gabbour" <tayssir.john@xxxxxxxxxxxxxx>
- Date: 17 Mar 2007 04:55:45 -0700
On Mar 17, 4:29 am, Vassil Nikolov <vnikolov+use...@xxxxxxxxx> wrote:
On Fri, 16 Mar 2007 16:03:46 -0400, Raffael Cavallaro said:
| * (defun kv-insert (list elt)
| (stable-sort (push elt list) #'string< :key #'car))
^^^^
Apart from any efficiency considerations (this is O(n log n), while
it can be just O(n)), this either needs a (COPY-LIST LIST) or a
comment explaining why the value is expendable. Also, the PUSH is
gratuitous; this is a job for CONS.
You could have O(n) and non-destructiveness with:
(defun kv-insert (list elt)
(merge 'list (copy-seq list) (list elt) #'string< :key #'car))
But you tell me
Over and over and over again, my friend
Ah, you don't believe
We're on the eve
of destruction.
Tayssir
.
- Follow-Ups:
- Re: Idiomatic lisp - loops
- From: Rob St. Amant
- Re: Idiomatic lisp - loops
- References:
- Idiomatic lisp - loops
- From: oversby
- Re: Idiomatic lisp - loops
- From: Raffael Cavallaro
- Re: Idiomatic lisp - loops
- From: Vassil Nikolov
- Idiomatic lisp - loops
- Prev by Date: Re: "Another Glitch In The Call" Lisp Song Text
- Next by Date: Re: cons to the same object
- Previous by thread: Re: Idiomatic lisp - loops
- Next by thread: Re: Idiomatic lisp - loops
- Index(es):
Relevant Pages
|