Re: Non-destructive sorts?
- From: Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx>
- Date: Sun, 29 Oct 2006 03:55:58 +0100
"robinganemccalla@xxxxxxxxx" <robinganemccalla@xxxxxxxxx> writes:
I want to know how (if it is possible) to have the following function
calls not alter the original values of my two lists
Of course. Copy the sequence first!
(defun sort-value (Entry1 Entry2)
(> (car Entry1) (car Entry2)))
(defun get-values (hand)
(mapcar #'cadr (stable-sort hand #'sort-value)))
(setq flist '((1 2) (3 4) (2 1)))
(setq glist '((5 8) (8 3)))
(setq tlist (append flist glist))
(get-values tlist)
when I do this, not only do I get different values for successive
calls, but the value of glist and flist change.
(defun get-values (hand)
(map 'list (function cadr)
(stable-sort (copy-seq hand) (function >) :key (function car))))
--
__Pascal Bourguignon__ http://www.informatimago.com/
Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we. -- Georges W. Bush
.
- References:
- Non-destructive sorts?
- From: robinganemccalla@xxxxxxxxx
- Non-destructive sorts?
- Prev by Date: Re: Using lisp to generate .net business applications
- Next by Date: Re: Non-destructive sorts?
- Previous by thread: Non-destructive sorts?
- Next by thread: Re: Non-destructive sorts?
- Index(es):
Relevant Pages
|
|