www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Object-based interface for a range of ranges

reply =?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu> writes:
This works:

     int[][] a;
     RandomAccessFinite!(int[]) r = inputRangeObject(a);

What would be a good way to achieve something equivalent to this?:

     int[][] a;
     RandomAccessFinite!(RandomAccessFinite!int) r = 
inputRangeObject(a);
Jan 27 2016
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 01/27/2016 08:59 PM, Luís Marques wrote:
 This works:

      int[][] a;
      RandomAccessFinite!(int[]) r = inputRangeObject(a);

 What would be a good way to achieve something equivalent to this?:

      int[][] a;
      RandomAccessFinite!(RandomAccessFinite!int) r = inputRangeObject(a);
All I can say is the following compiles. I hope it works too. :) import std.range; import std.algorithm; import std.conv; void main() { int[][] a; RandomAccessFinite!(RandomAccessFinite!int) r = inputRangeObject( a.map!(e => inputRangeObject(e).to!(RandomAccessFinite!int))); } Instead of to!(RandomAccessFinite!int) one can use the cast operator as well. Ali
Jan 27 2016