<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>I like it.<br><br><br>Inicio del mensaje reenviado:<br><br></div><blockquote type="cite"><div><b>De:</b> Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>><br><b>Fecha:</b> 16 de enero de 2017, 5:15:23 PM GMT+1<br><b>Para:</b> <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br><b>Asunto:</b> <b>Re: [swift-evolution] Reduce with inout</b><br><b>Responder a:</b> Dave Abrahams <<a href="mailto:dabrahams@apple.com">dabrahams@apple.com</a>><br><br></div></blockquote><blockquote type="cite"><div><span></span><br><span>on Mon Jan 16 2017, Chris Eidhof <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:</span><br><span></span><br><blockquote type="cite"><span>Hi,</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>How does everyone feel about adding a second version of `reduce` to</span><br></blockquote><blockquote type="cite"><span>`Sequence`? Instead of a `combine` function that's of type `(A, Element) -></span><br></blockquote><blockquote type="cite"><span>A`, it would be `(inout A, Element) -> ()`. This way, we can write nice</span><br></blockquote><blockquote type="cite"><span>functionals algorithms, but have the benefits of inout (mutation within the</span><br></blockquote><blockquote type="cite"><span>function, and hopefully some copy eliminations).</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>IIRC, Loïc Lecrenier first asked this on Twitter. I've been using it ever</span><br></blockquote><blockquote type="cite"><span>since, because it can really improve readability (the possible performance</span><br></blockquote><blockquote type="cite"><span>gain is nice, too).</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Here's `reduce` with an `inout` parameter, including a sample:</span><br></blockquote><blockquote type="cite"><span><a href="https://gist.github.com/chriseidhof/fd3e9aa621569752d1b04230f92969d7">https://gist.github.com/chriseidhof/fd3e9aa621569752d1b04230f92969d7</a></span><br></blockquote><span></span><br><span>+1</span><br><span></span><br><span>-- </span><br><span>-Dave</span><br><span></span><br><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>