Re: the sort function in lisp (destructive)
- From: Madhu <enometh@xxxxxxxx>
- Date: Mon, 07 Jan 2008 11:38:00 +0530
* Gene <3d734438-8f14-48ab-95f6-46aec08e7249@xxxxxxxxxxxxxxxxxxxxxxxxxxx> :
Wrote on Sun, 6 Jan 2008 13:20:31 -0800 (PST):
|> > In fact looking at the source for Corman Lisp I discovered that it
|> > reads the CAR into a vector, sorts that, and then puts the values
|> > back in the CAR's in sorted order.
|>
|> This might have been done for other reasons than avoiding side-effect.
|> For example, to avoid having two different sort algorithms, or even
|> because it didn't occur to him how to write the algorithm without
|> doing indexed access.
|>
| Another possible reason is to avoid a certain kind of degenerate cache/
| paging behavior. If you sort a long, randomly ordered list by
| changing cdr's, merely traversing the resulting list cells makes for a
| terrible memory access pattern.
I think there are two many `if's in reasoning about memory access
patterns. You will traverse the list to get it into the array in the
first place, and there may be repeated traversals immediately , on the
resulting list.
But I notice you have made this point in the past, when citing
your paper which exhibited a SHUFFLE algorithm which worked on cons
cells. I could not look it up, perhaps you could post a brief
description of how it worked here?
[As for SORT Robert Maas posted a small hack that would preserve the head
cons after calling the implementation's SORT in SORT-KEEPING-HEAD-CELL
in his post[1] <News:rem-2007oct11-003@xxxxxxxxx>
Dated "11 Oct 2007 02:44:41 -0700"]
--
Madhu
[1] (rem-2007oct11-003 @ yahoo.com)
.
- Follow-Ups:
- Re: the sort function in lisp (destructive)
- From: Gene
- Re: the sort function in lisp (destructive)
- From: Robert Maas, see http://tinyurl.com/uh3t
- Re: the sort function in lisp (destructive)
- References:
- Re: the sort function in lisp (destructive)
- From: Alex Mizrahi
- Re: the sort function in lisp (destructive)
- From: Rainer Joswig
- Re: the sort function in lisp (destructive)
- From: John Thingstad
- Re: the sort function in lisp (destructive)
- From: Gene
- Re: the sort function in lisp (destructive)
- Prev by Date: Re: Few questions about deftype, subtype and initialization
- Next by Date: Re: changing text color
- Previous by thread: Re: the sort function in lisp (destructive)
- Next by thread: Re: the sort function in lisp (destructive)
- Index(es):
Relevant Pages
|