Re: Rust-like collect in D

2016-10-13 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 13 October 2016 at 10:00:56 UTC, Nordlöw wrote: For instance, we can use `if (!isInfinite!Range)` to forbid collecting values from an infinite `Range`. Is this checking done? That is `0.iota.make!Array` should not be allowed. https://github.com/dlang/phobos/pull/4860

Re: Rust-like collect in D

2016-10-12 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2016-10-12 at 21:15 -0400, Andrei Alexandrescu via Digitalmars- d-learn 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.colle > > ct > > That's "make" in

Re: Rust-like collect in D

2016-10-12 Thread Russel Winder via Digitalmars-d-learn
On Thu, 2016-10-13 at 02:33 +, 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`: > > > > > >

Re: Rust-like collect in D

2016-10-12 Thread Meta via Digitalmars-d-learn
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.collect That's "make" in std.container. Is that what you're

Re: Rust-like collect in D

2016-10-12 Thread Andrei Alexandrescu via Digitalmars-d-learn
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.collect That's "make" in std.container. Is that what you're looking for? As an aside, "collect" is an awful abbreviation of "collection".

Re: Rust-like collect in D

2016-10-06 Thread ag0aep6g via Digitalmars-d-learn
On 10/06/2016 07:44 PM, ag0aep6g wrote: https://dlang.org/phobos/std_container_util.html#.make More specifically, the second overload is where it's at: https://dlang.org/phobos/std_container_util.html#.make.2

Re: Rust-like collect in D

2016-10-06 Thread ag0aep6g via Digitalmars-d-learn
On 10/06/2016 04:32 PM, 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.collect If not, I'm eager to implement it to support D-style containers. What would the desired interface look like? Perhaps:

Re: Rust-like collect in D

2016-10-06 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 6 October 2016 at 17:22:10 UTC, Dicebot wrote: On Thursday, 6 October 2016 at 16:56:26 UTC, Nordlöw wrote: Is there a way to do this, or do we need something similar to `collect` in Phobos? Something like import std.container.array : Array; 0.iota(n).collect!Array You mean

Re: Rust-like collect in D

2016-10-06 Thread Dicebot via Digitalmars-d-learn
On Thursday, 6 October 2016 at 16:56:26 UTC, Nordlöw wrote: Is there a way to do this, or do we need something similar to `collect` in Phobos? Something like import std.container.array : Array; 0.iota(n).collect!Array You mean semantics like this? Container collect(Container, Range) (Range

Re: Rust-like collect in D

2016-10-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, October 06, 2016 16:56:26 Nordlöw via Digitalmars-d-learn wrote: > On Thursday, 6 October 2016 at 16:14:33 UTC, Dicebot wrote: > > If an entity (i.e. container) implements OutputRange API, you > > can already do it: > > > > 0.iota(n).copy(container); > > Ahh, not quite what I

Re: Rust-like collect in D

2016-10-06 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 6 October 2016 at 16:14:33 UTC, Dicebot wrote: If an entity (i.e. container) implements OutputRange API, you can already do it: 0.iota(n).copy(container); Ahh, not quite what I wanted... I want to mimic the functional style Rust provides, where the `container` is constructed

Re: Rust-like collect in D

2016-10-06 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 6 October 2016 at 16:14:33 UTC, Dicebot wrote: If an entity (i.e. container) implements OutputRange API, you can already do it: 0.iota(n).copy(container); Thanks, that's what I was looking for.

Re: Rust-like collect in D

2016-10-06 Thread Dicebot via Digitalmars-d-learn
On Thursday, 6 October 2016 at 14:32:44 UTC, 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.collect If not, I'm eager to implement it to support D-style containers. What would the desired interface look like?

Re: Rust-like collect in D

2016-10-06 Thread cym13 via Digitalmars-d-learn
On Thursday, 6 October 2016 at 14:58:34 UTC, Nordlöw wrote: On Thursday, 6 October 2016 at 14:33:59 UTC, rikki cattermole wrote: So an input range to array? Sure std.array : array. No, we want a generic alternative that fills any kind of container, typically non-GC allocated. Sounds like

Re: Rust-like collect in D

2016-10-06 Thread Nordlöw via Digitalmars-d-learn
On Thursday, 6 October 2016 at 14:33:59 UTC, rikki cattermole wrote: So an input range to array? Sure std.array : array. No, we want a generic alternative that fills any kind of container, typically non-GC allocated.

Re: Rust-like collect in D

2016-10-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/10/2016 3: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.collect If not, I'm eager to implement it to support D-style containers. What would the desired interface look like? Perhaps:

Rust-like collect in D

2016-10-06 Thread Nordlöw via Digitalmars-d-learn
Is there a concept in D similar to Rust's `collect`: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect If not, I'm eager to implement it to support D-style containers. What would the desired interface look like? Perhaps: 0.iota(n).collect!Array Or can/should we just