Re: Sorted Sets With Duplicate Elements

2012-11-20 Thread Mark Engelberg
On Tue, Nov 20, 2012 at 11:08 AM, Andy Fingerhut wrote: > > Then my question is still: "Would it be good for Clojure to document and > promise this comparison behavior?" > > If not for all cases, at least for equal-length vectors being compared > lexicographically? > > I frequently rely on Clojure

Re: Sorted Sets With Duplicate Elements

2012-11-20 Thread Andy Fingerhut
On Nov 20, 2012, at 11:04 AM, Alan Malloy wrote: > On Tuesday, November 20, 2012 10:29:18 AM UTC-8, Andy Fingerhut wrote: > > On Nov 20, 2012, at 10:12 AM, Mark Engelberg wrote: > > > Clojure's sorted collections must be provided with a sorting function where > > items "tie" if and only if th

Re: Sorted Sets With Duplicate Elements

2012-11-20 Thread Alan Malloy
On Tuesday, November 20, 2012 10:29:18 AM UTC-8, Andy Fingerhut wrote: > > > On Nov 20, 2012, at 10:12 AM, Mark Engelberg wrote: > > > Clojure's sorted collections must be provided with a sorting function > where items "tie" if and only if they are equal. > > > > (sorted-set-by #(compare [(se

Re: Sorted Sets With Duplicate Elements

2012-11-20 Thread Andy Fingerhut
On Nov 20, 2012, at 10:12 AM, Mark Engelberg wrote: > Clojure's sorted collections must be provided with a sorting function where > items "tie" if and only if they are equal. > > (sorted-set-by #(compare [(second %) %] [(second %2) %2]) [:a 1] [:b 1] [:c > 1])) Mark, I like the brevity of th

Re: Sorted Sets With Duplicate Elements

2012-11-20 Thread JvJ
Thanks for the tip. On Tuesday, 20 November 2012 13:13:09 UTC-5, puzzler wrote: > > On Tue, Nov 20, 2012 at 8:01 AM, JvJ >wrote: > >> Simple solution. It works! Thanks. >> > > No, it doesn't work. It may print correctly now, but it won't actually > behave the way you expect. > > Clojure's sort

Re: Sorted Sets With Duplicate Elements

2012-11-20 Thread Mark Engelberg
On Tue, Nov 20, 2012 at 8:01 AM, JvJ wrote: > Simple solution. It works! Thanks. > No, it doesn't work. It may print correctly now, but it won't actually behave the way you expect. Clojure's sorted collections must be provided with a sorting function where items "tie" if and only if they are

Re: Sorted Sets With Duplicate Elements

2012-11-20 Thread Andy Fingerhut
I would be surprised if you are still happy with that solution a few minutes after doing some testing with it. I've added some examples to ClojureDocs.org at the link below, with a suggested better comparison function. Take a look and let me know if it seems clear: http://clojuredocs.org/cloju

Re: Sorted Sets With Duplicate Elements

2012-11-20 Thread JvJ
Simple solution. It works! Thanks. On Tuesday, 20 November 2012 10:59:23 UTC-5, Bronsa wrote: > > what about using <= as sorting fuction? > > 2012/11/20 JvJ > > >> First of all: I don't EXACTLY mean duplicate elements. I just mean >> duplicates in those parts of the elements which are compare

Re: Sorted Sets With Duplicate Elements

2012-11-20 Thread Bronsa
what about using <= as sorting fuction? 2012/11/20 JvJ > First of all: I don't EXACTLY mean duplicate elements. I just mean > duplicates in those parts of the elements which are compared. > > For instance, I recently tried to have a sorted set of 2-element vectors > where the comparator < was