On Fri, Jan 9, 2009 at 8:28 AM, Chouser wrote:
> So maybe leaving 'sort' undefined for lists makes sense. If you want
> them to sort like vectors, then use vectors!
But if the lists are nested within some aggregate structure, (e.g., in
the original postr's use case, the lists were the second el
On Fri, Jan 9, 2009 at 2:59 AM, Mark Engelberg wrote:
>
> Lexicographic ordering. Compare the first elements, if equal compare the
> rests.
Which is how vectors sort:
user=> (sort [[3 2 1] [1 2 3]])
([1 2 3] [3 2 1])
But vector grow on the right, like English words, so using
English-word-lik
On Thu, Jan 8, 2009 at 11:20 PM, Christian Vest Hansen
wrote:
> Comparable implies that an Object can be reduced to a scalar value, if
> only for the purpose of comparing. How do you imagine this should work
> on list of arbitrary things?
Lexicographic ordering. Compare the first elements, if e
On Thu, Jan 8, 2009 at 11:38 PM, Dmitri wrote:
>
> I think the main issue is that sort should behave consistently.
> Possibly sort could check if the elements implement Comparable before
> attempting to sort them?
> I also don't see a reason as to why the lists
> shouldn't implement Comparable.
I think the main issue is that sort should behave consistently.
Possibly sort could check if the elements implement Comparable before
attempting to sort them? I also don't see a reason as to why the lists
shouldn't implement Comparable.
On Jan 8, 4:17 pm, "Mark Engelberg" wrote:
> Lists are not
Lists are not comparable (i.e., you can't do something like (< '(1 2
3) '(4 5 6))). So you can't sort a collection of lists, but you can
sort a collection of vectors (provided the vectors contain comparable
things). This is always the case; there is no inconsistency.
The reason you are sometime
I tried this again with the latest build from svn, and it seems that
lists may be running into a race condition due to their lazy nature:
Exception in thread "main" java.lang.RuntimeException:
java.lang.ClassCastException: clojure.lang.LazyCons cannot be cast to
java.lang.Comparable
On Jan 8, 2:
On Jan 8, 2009, at 1:55 PM, Dmitri wrote:
There are two issues here that I'm seeing, first is that the list and
vector have different behavior, my understanding is that they are both
sequences and one should be able to perform the same operations on
them.
I don't know more about the underlyin
There are two issues here that I'm seeing, first is that the list and
vector have different behavior, my understanding is that they are both
sequences and one should be able to perform the same operations on
them.
Second issue is that the behavior is inconsistent, if it is not
possible to sort tu
I wonder if the root cause might be clearer if you were to review the
documentation for the sort function and then apply what it says to a
smaller dataset, e.g. a pair of lists.
Bill
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
I noticed strange behavior in the sort function, I was sorting key
value tuples and ran into the following:
when sorting 2 item vectors such as [1 [1 2 3]] sort works fine:
(println
(sort
(map
(fn [x] [(int (* (Math/random) 10)) x]) (for [x (range 4)]
[1 2 3]
output:
(
11 matches
Mail list logo