<div dir="ltr">What about `reducing(x, combine: {...})`</div><div class="gmail_extra"><br><div class="gmail_quote">On 18 January 2017 at 07:47, Xiaodi Wu via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">A serious possibility would be: `reduce(mutableCopyOf: x) { ... }`.<div><br></div><div>It's verbose, but the nicer-looking `reduce(mutating: x) { ... }` is incorrect since, as Charles pointed out to Dave, it's not `x` that's mutated but rather a mutable copy of it, so it doesn't matter if `x` itself is declared with `let` or `var`. <div><div class="h5"><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"><<a href="mailto:sean@fifthace.com" target="_blank">sean@fifthace.com</a>></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="m_6639886365703819284HOEnZb"><font color="#888888">Sean<br>
</font></span><div class="m_6639886365703819284HOEnZb"><div class="m_6639886365703819284h5"><br>
<br>
> On Jan 17, 2017, at 7:36 PM, T.J. Usiyan via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
><br>
> `reduceInout`<br>
><br>
> On Tue, Jan 17, 2017 at 6:30 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
> Agree. The functional style should keep the functional name.<br>
><br>
> On Tue, Jan 17, 2017 at 16:18 David Sweeris via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
><br>
> On Jan 17, 2017, at 16:11, Karl Wagner via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
><br>
>><br>
>>> On 17 Jan 2017, at 23:09, Karl Wagner <<a href="mailto:karl.swift@springsup.com" target="_blank">karl.swift@springsup.com</a>> wrote:<br>
>>><br>
>>><br>
>>>> On 16 Jan 2017, at 14:49, Chris Eidhof via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br>
>>>><br>
>>>> Hi,<br>
>>>><br>
>>>> How does everyone feel about adding a second version of `reduce` to `Sequence`? Instead of a `combine` function that's of type `(A, Element) -> A`, it would be `(inout A, Element) -> ()`. This way, we can write nice functionals algorithms, but have the benefits of inout (mutation within the function, and hopefully some copy eliminations).<br>
>>>><br>
>>>> IIRC, Loïc Lecrenier first asked this on Twitter. I've been using it ever since, because it can really improve readability (the possible performance gain is nice, too).<br>
>>>><br>
>>>> Here'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/chrise<wbr>idhof/fd3e9aa621569752d1b04230<wbr>f92969d7</a><br>
>>>><br>
>>>> --<br>
>>>> Chris Eidhof<br>
>>>> ______________________________<wbr>_________________<br>
>>>> swift-evolution mailing list<br>
>>>> <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
>>>> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br>
>>><br>
>>> +1<br>
>>><br>
>>> I would even argue for it to be the default.<br>
>><br>
>> 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>
><br>
> IIRC, the "reduce" name comes from functional programming... should the functional style keep the functional name?<br>
><br>
> - Dave Sweeris<br>
> ______________________________<wbr>_________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br>
><br>
> ______________________________<wbr>_________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br>
<br>
</div></div></blockquote></div><br></div></div></div></div></div></div></div>
<br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<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></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><font color="#999999" size="2" face="georgia, serif"><i>Pranshu Goyal</i></font><div><font color="#999999" size="2" face="times new roman, serif"><i>iOS Developer</i></font></div><div><font color="#999999" size="2" face="times new roman, serif"><i>tlkn</i></font></div></div></div>
</div>