<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions in math.combinatorics</title>
<link>https://ask.clojure.org/index.php/questions/contrib-libs/math-combinatorics</link>
<description></description>
<item>
<title>clojure.math.combinatorics/partitions can throw error with duplicate items and :min &amp; :max args</title>
<link>https://ask.clojure.org/index.php/12673/clojure-combinatorics-partitions-throw-error-duplicate-items</link>
<description>&lt;p&gt;When called with some duplicate items in &lt;code&gt;items&lt;/code&gt; and with a &lt;code&gt;:min&lt;/code&gt; &amp;amp; &lt;code&gt;:max&lt;/code&gt; supplied, &lt;code&gt;clojure.math.combinatorics/partitions&lt;/code&gt; can throw an &lt;code&gt;IndexOutOfBoundsException&lt;/code&gt;. For example:&lt;br&gt;
&lt;code&gt;(dorun (clojure.math.combinatorics/partitions [1 1 2 3 4 5] :min 5 :max 5))
Execution error (IndexOutOfBoundsException) at clojure.math.combinatorics/m5$fn (combinatorics.cljc:859).&lt;/code&gt;&lt;br&gt;
I can't replicate this when &lt;code&gt;items&lt;/code&gt; doesn't include at least one duplicate, nor can I replicate it when &lt;code&gt;:min&lt;/code&gt; isn't at least &lt;code&gt;5&lt;/code&gt;. I think &lt;code&gt;:max&lt;/code&gt; has to be supplied, but doesn't always have to be equal to &lt;code&gt;:min&lt;/code&gt;.&lt;br&gt;
It happens with non-number items, and regardless of the order of &lt;code&gt;items&lt;/code&gt;. It seems that it occurs when the first item is duplicated, but not for the other items.&lt;/p&gt;
</description>
<category>math.combinatorics</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12673/clojure-combinatorics-partitions-throw-error-duplicate-items</guid>
<pubDate>Fri, 17 Feb 2023 16:04:50 +0000</pubDate>
</item>
<item>
<title>Allow maps as multi-sets</title>
<link>https://ask.clojure.org/index.php/7570/allow-maps-as-multi-sets</link>
<description>&lt;p&gt;Frequency maps are often the most natural way of expressing multi-sets in Clojure, eg. {{{:a 3 :b 2}}} is a set (unordered) of 3 {{:a}}'s and 2 {{:b}}'s: {{[:a :a :a :b :b]}}. Unfortunately, math.combinatorics currently only accepts sets in the latter form ie. a collection of possibly repeated values. It would be nice if math.combinatorics functions either supported sets represented as frequency maps or had versions which did.&lt;/p&gt;
</description>
<category>math.combinatorics</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7570/allow-maps-as-multi-sets</guid>
<pubDate>Fri, 13 Jul 2018 11:00:12 +0000</pubDate>
</item>
<item>
<title>Better support for sets</title>
<link>https://ask.clojure.org/index.php/7571/better-support-for-sets</link>
<description>It seems reasonable to want to use a clojure set as the items parameter for the combinatoric functions. However, in the case of {{(combinations some-set 1)}}, an exception is raised because Clojure's distinct function (called when {{(= t 1)}}) does not support sets. This problem can be worked around by converting the set to a seq before calling combinations.&lt;br /&gt;
&lt;br /&gt;
For all the other functions, it appears extending {{all-different?}} with a {{set?}} check would make the functions slightly more efficient (by avoiding the linear {{distinct?}} scan).</description>
<category>math.combinatorics</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7571/better-support-for-sets</guid>
<pubDate>Sun, 12 Mar 2017 19:50:59 +0000</pubDate>
</item>
<item>
<title>Support ClojureScript by converting from CLJ to CLJC</title>
<link>https://ask.clojure.org/index.php/7569/support-clojurescript-by-converting-from-clj-to-cljc</link>
<description>&lt;p&gt;Patch attached with two changes:&lt;br&gt;
1) Rename main source file to change extension from .clj to .cljc.&lt;br&gt;
2) Add Clojure 1.7 dependency to pom.xml.&lt;/p&gt;
&lt;p&gt;Ran &quot;mvn clojure:test&quot; and confirmed that old tests still pass.&lt;/p&gt;
&lt;p&gt;Did not test in ClojureScript environment.&lt;/p&gt;
&lt;p&gt;Main downside is increasing the minimum Clojure version from 1.2 to 1.7 for CLJC support. Alex Miller also indicated that the Clojure CI system was not ready for CLJC files yet, but that it would be nice to have the ticket and patch ready.&lt;/p&gt;
&lt;p&gt;See previous clojure-dev discussion: &lt;a rel=&quot;nofollow&quot; href=&quot;https://groups.google.com/forum/#!topic/clojure-dev/PDyOklDEv7Y&quot;&gt;https://groups.google.com/forum/#!topic/clojure-dev/PDyOklDEv7Y&lt;/a&gt;&lt;/p&gt;
</description>
<category>math.combinatorics</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7569/support-clojurescript-by-converting-from-clj-to-cljc</guid>
<pubDate>Sat, 19 Mar 2016 04:42:07 +0000</pubDate>
</item>
<item>
<title>Please add project.clj</title>
<link>https://ask.clojure.org/index.php/7572/please-add-project-clj</link>
<description>&lt;p&gt;Is there a reason for not having a &lt;code&gt;project.clj&lt;/code&gt; in the project?&lt;/p&gt;
&lt;p&gt;I'd like to fork, run &lt;code&gt;lein test&lt;/code&gt; and &lt;code&gt;lein repl&lt;/code&gt;.&lt;/p&gt;
</description>
<category>math.combinatorics</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7572/please-add-project-clj</guid>
<pubDate>Sun, 23 Jun 2013 23:27:44 +0000</pubDate>
</item>
</channel>
</rss>