[swift-evolution] [swift-evolution-announce] [Review] SE-0045: Add scan, prefix(while:), drop(while:), and iterate to the stdlib

Dave Abrahams dabrahams at apple.com
Thu Apr 28 17:09:58 CDT 2016


on Thu Apr 28 2016, Pyry Jahkola <swift-evolution at swift.org> wrote:

>     I would really like a different name for scan. While it’s the term of art
>     for Haskell and co, it really seems meaningless to regular programmers (why
>     is “scanning” the way you produce an array of intermediate reduces?), and it
>     would be better to follow the pattern already established elsewhere in the
>     library to give friendlier names e.g. flatMap instead of bind, reduce
>     instead of fold.
>
>     I think Python calls it accumulate:
>     http://docs.python.org/3/library/itertools.html#itertools.accumulate
>
> FWIW, Clojure calls it `reductions` which aligns pretty nicely with the `reduce
> ` counterpart.

That's cute.

>     I also think it would be nice for both scan and reduce to have overloads
>     that take the first value as the initial (and return an optional) but that’s
>     probably a separate proposal.
>
> +1
>
> — Pyry
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-- 
Dave



More information about the swift-evolution mailing list