Rust-like collect in D

Russel Winder via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 12 22:07:26 PDT 2016


On Thu, 2016-10-13 at 02:33 +0000, Meta via Digitalmars-d-learn wrote:
> On Thursday, 13 October 2016 at 01:15:22 UTC, Andrei Alexandrescu 
> wrote:
> > On 10/06/2016 10:32 AM, Nordlöw wrote:
> > > Is there a concept in D similar to Rust's `collect`:
> > > 
> > > https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.col
> > > lect
> > 
> > That's "make" in std.container. Is that what you're looking 
> > for? As an aside, "collect" is an awful abbreviation of 
> > "collection". -- Andrei
> 
> I've always thought of it more as "collect the elements of the 
> iterator into a container".

Java and Rust have gone the same route. collect is a terminal operation
creating a data structure given a potentially infinite, lazily
evaluated, stream. Rust uses iter for creating a stream from a data
structure, Java uses stream or parallelstream. Java's parallelstream
seems to be missing from Rust, but there is Rayon to provide a version.
D's std.parallelism does something of this, but it needs more work to
provide the tree-structured as well as scatter–gather internal
parallelism models.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20161013/fe9439d2/attachment.sig>


More information about the Digitalmars-d-learn mailing list