Re: Question about the sort function



So, I never claimed to have 10 years of experience (in case any of you
were wondering). For some reason I had the impression that calling
sort on a list left the list as a sorted list; Clisp & SBCL does this,
but it is not standard Common Lisp. I am very familiar with lisp and I
use many languages. Sadly enough, my memory is not infinite and I
sometimes forget the details. Let's just say, I won't forget this
detail about sort from now on. ;)

However wrong I was, I am the type of person that will not change my
solution without understanding the reasoning. Changing sort to stable-
sort would have made the problem work, but it was the wrong answer.
That is the reason I posted this question on the user group. The
reviewer may have been annoyed with the fact that I was challenging
his requested fix, but the fact is: his fix was incorrect. I always
assumed there was something I was doing wrong, but I was pretty sure
it had nothing to do with stable-sort vs sort.

Well damn, that is one out of ten lisp jobs that I cannot apply to
anymore. Oh well. Next time I will just agree and figure it out later.

PS. I am really not a difficult person, although I sure feel like one
right now.



On Oct 9, 10:12 am, w...@xxxxxxxxxxxxxxx (Bob Felts) wrote:
Rainer Joswig <jos...@xxxxxxx> wrote:
In article <1i5ow53.pskscln5nqbmN%w...@xxxxxxxxxxxxxxx>,
w...@xxxxxxxxxxxxxxx (Bob Felts) wrote:

...

Even for Common Lisp? The Hyperspec is clear that sort and stable-sort
are destructive. Maybe I'm being naive...

It is not intuitive (at least for me) that one sorts a list
and the variable pointing to that list is not updated
to point to the sorted list. It is a consequence of
Lisp evaluation rules an the type of lists (made of cons cells)
it uses, but may not clear for somebody
who also uses programming languages where you
can pass variables differently or lists are implemented differently.

It is a typical topic for a Common Lisp tutorial explaining
how destructive list operations should be used.

Well, even if the behavior of sort isn't intuitive (and I'm not arguing
that it is), shouldn't someone with 10 years of Lisp experience have
learned its behavior by then? I tend to think yes; Kent made an
argument that this might not be the case even with a good programmer.
I'm interested in other viewpoints. It seems to me that good artists
have to be familiar with their tools, and the more experienced claimed,
the better the familiarity. But, perhaps we agree on principle, but
aren't sure where to actually draw the line.


.



Relevant Pages

  • Panic, a strange behavior of lisp program
    ... when SORT is called with a parameter that includes some that ... No actually although CLtL ... this apparent mistake in conversion from CLtL to ANSI-CL. ... Web page that lists all such "obvious" mistakes. ...
    (comp.lang.lisp)
  • RE: Incident investigation methodologies
    ... However, what sort of reaction ... Speculation gets you nowhere. ... > malware we encounter. ... > of what makes public lists useful - you can get some ...
    (Incidents)
  • Re: Detailed explanation of how a QuickSort Works
    ... Firstly, if you consider the simple "Bubble Sort" algorithm, it works by running through the entire data set, one item at a time, comparing each item to the previous item and swapping them if they are not already in the correct order. ... by simply running through the entire list just once (and splitting it into two smaller lists) you have cut the sorting time in half. ...
    (microsoft.public.vb.general.discussion)
  • Re: Ordering Products
    ... algorithms. ... lists with constrained item transpositions. ... I think while the built in sort works as a convenience, ... Overall it's about 10 times slower than pythons built in sort for large ...
    (comp.lang.python)
  • Re: Ordering Products
    ... > Kay Schluehr wrote: ... >> It would be interesting to examine some sorting algorithms on factor ... >> lists with constrained item transpositions. ... > I think while the built in sort works as a convenience, ...
    (comp.lang.python)