Re: Ranges to deal with corner cases and "random access"

2019-10-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 8, 2019 9:40:33 AM MDT Paul Backus via Digitalmars-d- learn wrote: > On Sunday, 6 October 2019 at 20:34:55 UTC, Brett wrote: > > If it can be done and make to work well with ranges it would > > allow many algorithms to be very easily expressed and make > > ranges more powerful.

Re: Ranges to deal with corner cases and "random access"

2019-10-08 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 6 October 2019 at 20:34:55 UTC, Brett wrote: If it can be done and make to work well with ranges it would allow many algorithms to be very easily expressed and make ranges more powerful. You can make it a range by adding an "alias this" to the original array: struct

Re: Ranges to deal with corner cases and "random access"

2019-10-06 Thread Brett via Digitalmars-d-learn
Here is a sort of proof of concept: struct CtsExtend { static auto opCall(T)(T a) { struct _CtsExtend { T _a; auto opIndex(int i) { if (i < 0)

Re: Ranges to deal with corner cases and "random access"

2019-10-05 Thread 9il via Digitalmars-d-learn
On Saturday, 5 October 2019 at 00:38:06 UTC, Brett wrote: Typically a lot of algorithms have corner cases such as referencing elements that end up out of bounds at the start or end (k-c or k+c). [...] mir-algorithm package provides lazy padding and concatenation routines

Ranges to deal with corner cases and "random access"

2019-10-04 Thread Brett via Digitalmars-d-learn
Typically a lot of algorithms have corner cases such as referencing elements that end up out of bounds at the start or end (k-c or k+c). Is there any way to handle such things easily without having to worry about the corners? E.g., have it return a default value such as 0, or repeat the