[swift-evolution] Fwd: Reduce with inout

Step Christopher schristopher at bignerdranch.com
Mon Jan 16 11:36:30 CST 2017


I like it.


Inicio del mensaje reenviado:

> De: Dave Abrahams via swift-evolution <swift-evolution at swift.org>
> Fecha: 16 de enero de 2017, 5:15:23 PM GMT+1
> Para: swift-evolution at swift.org
> Asunto: Re: [swift-evolution] Reduce with inout
> Responder a: Dave Abrahams <dabrahams at apple.com>
> 
> 
>> on Mon Jan 16 2017, Chris Eidhof <swift-evolution at swift.org> wrote:
>> 
>> Hi,
>> 
>> 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).
>> 
>> 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).
>> 
>> Here's `reduce` with an `inout` parameter, including a sample:
>> https://gist.github.com/chriseidhof/fd3e9aa621569752d1b04230f92969d7
> 
> +1
> 
> -- 
> -Dave
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170116/934885e0/attachment-0001.html>


More information about the swift-evolution mailing list