I would like that feature too.<br><br>Wouldn't this require Swift to have settled its concurrency model (which in turn would require settling ownership and borrowing)?<br><br><div class="gmail_quote"><div dir="ltr">On Tue, Apr 18, 2017 at 03:03 Jonathan Hull 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">I would like to see Swift gain something similar to Clojure’s Reducers Library. Basically this is somewhat similar to our Sequence, but for tree-based structures instead of sequential ones. It allows a series of algorithms that operate using a divide and conquer strategy, and it is easy to massively parallelize.<br>
<br>
One interesting property is that, because you don’t have to work sequentially, you are able to take a series of calls that do the equivalent of map/filter/flatMap, and compose the functions to make a single call on each piece of data (thus you don’t have build or recurse over intermediate sequences). Everything can be done in a single pass (and that pass can be done in parallel). It can be a big win in terms of efficiency.<br>
<br>
Here is a blog post where someone benchmarked ‘fold’ from the reducers library (306ms) vs sequence-based reduce (1450ms):<br>
<a href="https://adambard.com/blog/clojure-reducers-for-mortals/" rel="noreferrer" target="_blank">https://adambard.com/blog/clojure-reducers-for-mortals/</a><br>
<br>
Here is another post explaining how the idea might work in Python:<br>
<a href="https://adambard.com/blog/Reducers-explained-through-Python/" rel="noreferrer" target="_blank">https://adambard.com/blog/Reducers-explained-through-Python/</a><br>
<br>
Finally here is a video one of the developers of Clojure talking about why this pattern is so great (just after the 19 min mark):<br>
<a href="https://www.infoq.com/presentations/Clojure-Design-Patterns" rel="noreferrer" target="_blank">https://www.infoq.com/presentations/Clojure-Design-Patterns</a><br>
<br>
Adding something like this to Swift would be a great boon by providing generic parallelizable algorithms…<br>
<br>
Thanks,<br>
Jon<br>
_______________________________________________<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/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>