Re: simple range question

2016-04-08 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Friday, 8 April 2016 at 18:27:59 UTC, Laeeth Isharc wrote: suppose I have a forward or random access range. what's the best way to compare each element with the element 4 elements prior to that element? I could map each element to a tuple of the element and the element 4 bars previously

Re: simple range question

2016-04-08 Thread jmh530 via Digitalmars-d-learn
On Friday, 8 April 2016 at 18:27:59 UTC, Laeeth Isharc wrote: suppose I have a forward or random access range. what's the best way to compare each element with the element 4 elements prior to that element? I could map each element to a tuple of the element and the element 4 bars previously

Re: simple range question

2016-04-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, April 08, 2016 18:27:59 Laeeth Isharc via Digitalmars-d-learn wrote: > suppose I have a forward or random access range. what's the best > way to compare each element with the element 4 elements prior to > that element? I could map each element to a tuple of the element > and the

simple range question

2016-04-08 Thread Laeeth Isharc via Digitalmars-d-learn
suppose I have a forward or random access range. what's the best way to compare each element with the element 4 elements prior to that element? I could map each element to a tuple of the element and the element 4 bars previously and do it that way. any neater way ?

Range question

2012-02-17 Thread H. S. Teoh
I'm trying to write a range-based template that iterates over a range and returns one of its elements according to some criterion: ElementType!R choose(R, E)(R range) if (isInputRange!R) { ElementType!R e; while (!range.empty) {

Re: Range question

2012-02-17 Thread Mantis
18.02.2012 2:50, H. S. Teoh пишет: ... You cannot have ref local variable, so e is a copy in any case. It may be a class reference or a pointer, so calling potentially non-const methods is probably not safe here, but assignment shouldn't give you problems.

Re: Range question

2012-02-17 Thread H. S. Teoh
On Sat, Feb 18, 2012 at 05:19:52AM +0200, Mantis wrote: 18.02.2012 2:50, H. S. Teoh пишет: ... You cannot have ref local variable, so e is a copy in any case. It may be a class reference or a pointer, so calling potentially non-const methods is probably not safe here, but assignment

Re: Range question

2012-02-17 Thread Mantis
18.02.2012 7:51, H. S. Teoh пишет: On Sat, Feb 18, 2012 at 05:19:52AM +0200, Mantis wrote: 18.02.2012 2:50, H. S. Teoh пишет: ... You cannot have ref local variable, so e is a copy in any case. It may be a class reference or a pointer, so calling potentially non-const methods is probably not

Re: Range question

2012-02-17 Thread H. S. Teoh
On Sat, Feb 18, 2012 at 08:02:15AM +0200, Mantis wrote: 18.02.2012 7:51, H. S. Teoh пишет: On Sat, Feb 18, 2012 at 05:19:52AM +0200, Mantis wrote: 18.02.2012 2:50, H. S. Teoh пишет: ... You cannot have ref local variable, so e is a copy in any case. It may be a class reference or a pointer,

Re: Range question

2012-02-17 Thread Jonathan M Davis
On Friday, February 17, 2012 22:27:06 H. S. Teoh wrote: Hmm. But the problem is that I want to be able to handle something like File.byLine(). Or perhaps what I really need is just to write a wrapper around File.readln() that ensures immutability, then I can use isImmutable() to enforce safety