<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged collection</title>
<link>https://ask.clojure.org/index.php/tag/collection</link>
<description></description>
<item>
<title>There is currently no option for `partition` to use the advantage of transducers.</title>
<link>https://ask.clojure.org/index.php/13187/there-currently-option-for-partition-advantage-transducers</link>
<description>&lt;p&gt;As said in the title. There are several options to solve this problem:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Introduce the 1-arity only for &lt;code&gt;(partition n coll)&lt;/code&gt;, which keeps the current standard pattern. It doesn't however allow the other arities and attempting to call &lt;code&gt;(partition n step)&lt;/code&gt; or &lt;code&gt;(partition n step coll)&lt;/code&gt; would result to unexpected behavior. That could be solved by checks of &lt;code&gt;(seqable? step-or-coll)&lt;/code&gt; or similar things.&lt;/li&gt;
&lt;li&gt;The 1-arity would be passed as a vector. That could solve the arity collision problem but itwould break the pattern.&lt;/li&gt;
&lt;li&gt;Introduce a function like &lt;code&gt;partition-xf&lt;/code&gt; that would do the work. The only issues could be that this function only returns a transducer, which is not common and that some people could expect the &lt;code&gt;partition&lt;/code&gt; function to return a transducer if called like &lt;code&gt;(partition n step)&lt;/code&gt;, but I think it's just about getting used to it like everything else.&lt;/li&gt;
&lt;/ol&gt;
</description>
<category>Transducers</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13187/there-currently-option-for-partition-advantage-transducers</guid>
<pubDate>Tue, 22 Aug 2023 18:23:14 +0000</pubDate>
</item>
</channel>
</rss>