<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 16 Jan 2017, at 14:49, Chris Eidhof via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi,<div class=""><br class=""></div><div class="">How does everyone feel about adding a second version of `reduce` to `Sequence`? Instead of a `combine` function that'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).</div><div class=""><br class=""></div><div class="">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).</div><div class=""><br class=""></div><div class="">Here's `reduce` with an `inout` parameter, including a sample: <a href="https://gist.github.com/chriseidhof/fd3e9aa621569752d1b04230f92969d7" class="">https://gist.github.com/chriseidhof/fd3e9aa621569752d1b04230f92969d7</a><br class=""></div><div class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature">Chris Eidhof</div>
</div></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""><div class="">+1</div><div class=""><br class=""></div><div class="">I would even argue for it to be the default.</div></body></html>