On May 17, 4:35 am, Ken Wesson <kwess...@gmail.com> wrote:
> On Mon, May 16, 2011 at 9:44 AM, Fogus <mefo...@gmail.com> wrote:
> > Hi Ken,
>
> > Thanks for this.  I agree that a different name would be much more
> > clear.
>
> Here's one from chapter 7. Section 7.1.2, near the end, has:
>
> "Perhaps you see a familiar pattern: we apply the column-names vector
> as a function across a set of indices, building a sequence of its
> elements at those indices. This action will return a sequence of the
> values of that row for the supplied column names, which is then turned
> into a vector so that it can then be used as the sorting function"
>
> This does not seem to be correct. It seems to be applying the row map
> as a function across a seq of column names, building a sequence of its
> elements at those column keys. This action will return a sequence of
> the values of that row for the supplied column names, which is then
> turned into a vector so that it can then be used as the sort key. The
> function that *returns* the vector is the sorting function.
>
> (Interesting that sort will sort vectors, by "lexicographic" ordering.
> It doesn't seem to like lists, though, which is odd since the same
> rule would naturally apply. (Sure it could hang on infinite seqs, but
> so do lots of other functions, such as print and doall. And it could
> be implemented, probably fairly easily, to consume only as much of a
> seq as was needed to determine the sort position; then it would only
> hang if it hit two infinite seqs that were equal, e.g. two copies of
> (iterate inc 1).))

Vectors implement Comparable, and lists don't. I don't see any clear
reason for this, but patching sort is the wrong answer: instead
implement Comparable for lists.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to