Simple casting?
Timon Gehr
timon.gehr at gmx.ch
Wed Nov 27 14:40:56 UTC 2019
On 27.11.19 11:43, ixid wrote:
> On Tuesday, 26 November 2019 at 16:33:06 UTC, Timon Gehr wrote:
>> import std;
>> void main(){
>> int[] x=[1,1,2,3,4,4];
>> int[][] y=x.chunkBy!((a,b)=>a==b).map!array.array;
>> writeln(y);
>> }
>
> This stuff is a nightmare for less experienced users like myself, I wish
> there were a single function that would make any data obkect eager, no
> matter how convoluted its arrays of arrays of arrays.
import std;
auto eager(T)(T r){
static if(isInputRange!T) return r.map!eager.array;
else return r;
}
void main(){
int[] x=[1,1,2,3,4,4];
int[][] y=x.chunkBy!((a,b)=>a==b).eager;
writeln(y);
}
More information about the Digitalmars-d-learn
mailing list