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 with sets yet there is little reason to complicate it. The nth-not-supported-on-hash-set exception is not too informative, though. On Wednesday, March 23, 2016 at 11:36:15 PM UTC-4, puzzler wrote: > > On Wed, Mar 23, 2016 at 7:05 PM, Matthias Grabmair <matthias...@gmail.com > <javascript:>> 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 produce permutations/combinations/etc. that are > lexicographic in terms of the index of the elements. > > In other words, if you ask for permutations of a three element sequence, > you'll always get back permutations in this order: > [first-element second-element third-element] > [first-element third-element second-element] > [second-element first-element third-element] > [second-element third-element first-element] > [third-element first-element second-element] > [third-element second-element first-element] > > This gives you control: it is up to you to put them in a seq (or vector) > in the order you want the elements, and then call the function. For a > traditional lexicographic order, you would sort the items before calling > the function. It doesn't make sense for the function to try to sort things > first, because in Clojure, many things are not comparable, and maybe that's > not the order you want anyway. > > This is why it is not built to accept sets. Sets have no notion of > order. If you are happy with just calling seq on the set and accepting > that order, great, you can do that, but you may want to do something more > specific (like sorting the elements). > > The reason you may want to sort the elements first is for testing > purposes. I believe that calling seq on a set can produce different > results depending on the way the set was built, so calling combinations on > two equal sets (that happened to be built differently) would produce > differently ordered results. If you put things into a seq in a certain > order, you're guaranteed to get the same result. > > Make sense? > -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.