Re: Pass range to a function

2017-07-28 Thread Meta via Digitalmars-d-learn
On Thursday, 27 July 2017 at 21:16:03 UTC, Chris wrote: I'm using regex `matchAll`, and mapping it to get a sequence of strings. I then want to pass that sequence to a function. What is the general "sequence of strings" type declaration I'd need to use? In C#, it'd be `IEnumerable`. I'd rathe

Re: Pass range to a function

2017-07-28 Thread Seb via Digitalmars-d-learn
On Thursday, 27 July 2017 at 21:16:03 UTC, Chris wrote: In C#, it'd be `IEnumerable`. I'd rather not do a to-array on the sequence, if possible. (e.g. It'd be nice to just pass the lazy sequence into my categorize function.) This comparison between Linq and D ranges might help you in the futu

Re: Pass range to a function

2017-07-27 Thread Ali Çehreli via Digitalmars-d-learn
On 07/27/2017 02:16 PM, Chris wrote: > What is the value of `???` in the following program: > void categorize(??? toks) { > foreach (t; toks) { > writeln(t); > } > } The easiest solution is to make it a template (R is a suitable template variable name for a range type): void categori

Pass range to a function

2017-07-27 Thread Chris via Digitalmars-d-learn
I'm using regex `matchAll`, and mapping it to get a sequence of strings. I then want to pass that sequence to a function. What is the general "sequence of strings" type declaration I'd need to use? In C#, it'd be `IEnumerable`. I'd rather not do a to-array on the sequence, if possible. (e.g.