<div dir="ltr">A serious possibility would be: `reduce(mutableCopyOf: x) { ... }`.<div><br></div><div>It&#39;s verbose, but the nicer-looking `reduce(mutating: x) { ... }` is incorrect since, as Charles pointed out to Dave, it&#39;s not `x` that&#39;s mutated but rather a mutable copy of it, so it doesn&#39;t matter if `x` itself is declared with `let` or `var`. <div><div><br></div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 17, 2017 at 7:46 PM, Sean Heber <span dir="ltr">&lt;<a href="mailto:sean@fifthace.com" target="_blank">sean@fifthace.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">`reuse`<br>
<br>
Then we just need an excuse for a function named ‘recycle’...<br>
<br>
l8r<br>
<span class="HOEnZb"><font color="#888888">Sean<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
&gt; On Jan 17, 2017, at 7:36 PM, T.J. Usiyan via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; `reduceInout`<br>
&gt;<br>
&gt; On Tue, Jan 17, 2017 at 6:30 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt; Agree. The functional style should keep the functional name.<br>
&gt;<br>
&gt; On Tue, Jan 17, 2017 at 16:18 David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; On Jan 17, 2017, at 16:11, Karl Wagner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; On 17 Jan 2017, at 23:09, Karl Wagner &lt;<a href="mailto:karl.swift@springsup.com">karl.swift@springsup.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On 16 Jan 2017, at 14:49, Chris Eidhof via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Hi,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; How does everyone feel about adding a second version of `reduce` to `Sequence`? Instead of a `combine` function that&#39;s of type `(A, Element) -&gt; A`, it would be `(inout A, Element) -&gt; ()`. This way, we can write nice functionals algorithms, but have the benefits of inout (mutation within the function, and hopefully some copy eliminations).<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; IIRC, Loïc Lecrenier first asked this on Twitter. I&#39;ve been using it ever since, because it can really improve readability (the possible performance gain is nice, too).<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Here&#39;s `reduce` with an `inout` parameter, including a sample: <a href="https://gist.github.com/chriseidhof/fd3e9aa621569752d1b04230f92969d7" rel="noreferrer" target="_blank">https://gist.github.com/<wbr>chriseidhof/<wbr>fd3e9aa621569752d1b04230f92969<wbr>d7</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; --<br>
&gt;&gt;&gt;&gt; Chris Eidhof<br>
&gt;&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt;&gt; swift-evolution mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt;&gt;&gt;&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; +1<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I would even argue for it to be the default.<br>
&gt;&gt;<br>
&gt;&gt; I mean, assuming having two “reduce”s would stress the typechecker, as Joe suggested it might, I would say “inout” makes sense to be the default and the other one can find itself a new name.<br>
&gt;<br>
&gt; IIRC, the &quot;reduce&quot; name comes from functional programming... should the functional style keep the functional name?<br>
&gt;<br>
&gt; - Dave Sweeris<br>
&gt; ______________________________<wbr>_________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
&gt;<br>
&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br>
</div></div></blockquote></div><br></div></div></div></div></div>