Subject: Re: Basic List processing
From: rpw3@rpw3.org (Rob Warnock)
Date: Tue, 11 Nov 2008 06:37:19 -0600
Newsgroups: comp.lang.lisp
Message-ID: <qrmdnWDF4Z3i4YTUnZ2dnUVZ_sbinZ2d@speakeasy.net>
Frank GOENNINGER  <dont-email-me@nomail.org> wrote:
+---------------
| rpw3@rpw3.org (Rob Warnock) writes:
| > Mark Carter <me@privacy.net> wrote:
| > +---------------
| > | Suppose I have: (defvar *list* '((1 2) (3 4) (5 6) (1 7)))
| > | Now, suppose I want the "keys" of the list, defined by the first element 
| > | of the list. Is there a Lisp function which is callable something like:
| > | (keys *list* :key #'first) ; => '(1 3 5)
| > +---------------
| >
| > Uh... What's wrong with just (MAPCAR #'FIRST *LIST*)?
| 
| It does not remove the duplicates ... - but something like this
| might do it:
| (defun keys (list)
|   (remove-duplicates (sort (copy-seq (mapcar 'car list)) #'<)))
+---------------

Yes, sorry. I didn't realize that I'd missed that portion of
the problem statement until I saw Rainer's parallel reply
(which also suggested MAPCAR and REMOVE-DUPLICATES).

+---------------
| > [Oh, and your example output is wrong...]
| 
| True. It is
| (1 3 5)
+---------------

*Yowch!* Two zingers in one!  [One to Mark, & one to me...]  ;-}


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607