Re: clojure.math.combinatorics/combinations throws exception on n=1

2016-03-26 Thread Matthias Grabmair
Yes, that's helpful. I think my use-case was probably closer to the selections-concepts as I was calling permutations right after. If the combinations function is order preserving then of course sets don't need to be covered. Thanks for the help! I guess if nobody has run into distinct-issues

Re: clojure.math.combinatorics/combinations throws exception on n=1

2016-03-24 Thread Alex Miller
I think this could be corrected by calling seq on the incoming coll (on the last line of the definition) and that would be in line with the rest of the seq functions in "seq"-ing their arg. This is kind of a degenerate case of course - sets are always distinct so (distinct ) should be the same

Re: clojure.math.combinatorics/combinations throws exception on n=1

2016-03-24 Thread Mark Engelberg
Looking at the source for distinct, the reason it fails is because it tries to destructure the set as a seq, and sets can't be destructured in this way. A lot of people think that (let [[f & r] coll] ...) is the same as (let [f (first coll), r (rest coll)]...), but they are not the same, because

Re: clojure.math.combinatorics/combinations throws exception on n=1

2016-03-24 Thread Erik Assum
Interesting that set doesn't implement distinct. It should be a pretty straight forward implementation. Erik. -- i farta > Den 24. mar. 2016 kl. 00.53 skrev Mark Engelberg : > > The input should be a sequence not a set, so call seq on the input before > passing it

Re: clojure.math.combinatorics/combinations throws exception on n=1

2016-03-23 Thread Mark Engelberg
On Wed, Mar 23, 2016 at 7:05 PM, Matthias Grabmair < matthias.grabm...@gmail.com> wrote: > > Thanks, this helps! > > Generally, is there any reason why combinations should not work on sets? I > may have tunnel vision here as they are everywhere in the systems I build. > > A lot of the functions

Re: clojure.math.combinatorics/combinations throws exception on n=1

2016-03-23 Thread Matthias Grabmair
Thanks, this helps! Generally, is there any reason why combinations should not work on sets? I may have tunnel vision here as they are everywhere in the systems I build. On Wednesday, March 23, 2016 at 7:54:05 PM UTC-4, puzzler wrote: > > The input should be a sequence not a set, so call seq

Re: clojure.math.combinatorics/combinations throws exception on n=1

2016-03-23 Thread Mark Engelberg
The input should be a sequence not a set, so call seq on the input before passing it to this function. Sorry if that was unclear from the docs. (For some inputs, it is more forgiving, but when you call combinations with n=1, it calls distinct on the set, and clojure.core's implementation of

clojure.math.combinatorics/combinations throws exception on n=1

2016-03-23 Thread Matthias Grabmair
I am just using the math combinatorics library and spent some time debugging until I found out that combinations does not accept n=1. Is this intentional? *=> (clojure.math.combinatorics/combinations #{1 2 3 4} 1)* *UnsupportedOperationException nth not supported on this type: