Hmm, it reads well, but IMO it avoids being misleading only because it doesn't mean anything. In what way are you reducing "into" the first argument any more so than the classic reduce function?<br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 24, 2017 at 12:44 Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Jan 24, 2017, at 12:36 PM, Pyry Jahkola via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_4877748158606825571Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><span class="gmail_msg"></span></div><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Freak Show wrote:<br class="gmail_msg"><br class="gmail_msg"></div><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">Am I the only one who finds this incredibly ugly and hard to read?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">This is more or less solved by inject:into: idiom. There is no reason for inout for this particular problem.</div></div></blockquote><br class="gmail_msg"><div class="gmail_msg">Yeah, the original signature seems more useful. If you go all `inout` like Gwendal suggested, you might as well just iterate over the sequence with `for x in xs`, updating the state as you go.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">But your comment brought another idea to mind: if `mutating:` is considered a bad name for a non-`inout` argument, how about `<b class="gmail_msg">reduce(into:combine:)`</b>, similar to what Karl suggested earlier in this thread?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I think it reads very well at the call site, does not suggest `inout`ness of the argument too much (of course there's no `&` at the call site either), and it's still easily found with auto-completion:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"> let counts = words.reduce(into: [:]) {</div></div><div class="gmail_msg"> $0[$1] = ($0[$1] ?? 0) + 1</div><div class="gmail_msg"> }</div></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">+1. This is concise and I think it captures the essence of what is happening pretty well!</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The third variation where the seed argument actually *is* `inout` might also be interesting in some cases where you *already* have a `var` that you want to accumulate into. I believe I have done this in the past in my own code but don’t have an example handy.</div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">— Pyry</div></div>_______________________________________________<br class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div></blockquote></div></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>