Iterators in structs

2020-06-25 Thread repr-man via Digitalmars-d-learn
As an extension of my previous thread (https://forum.dlang.org/thread/nupwljahyutnyxdvp...@forum.dlang.org), I wanted to ask about iterators in structs. I will start with the following code: void main() { int[5] a = [0, 1, 2, 3, 4]; int[5] b = [5, 6, 7, 8, 9]; auto x = ChunksOf(cha

Passing iterators into functions

2020-06-24 Thread repr-man via Digitalmars-d-learn
I have the code: int[5] a = [0, 1, 2, 3, 4]; int[5] b = [5, 6, 7, 8, 9]; auto x = chain(a[], b[]).chunks(5); writeln(x); It produces a range of slices as is expected: [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] However, when I define a function as follows and pass in the result of the chain iterator:

Passing a variable number of slices into a function

2020-06-21 Thread repr-man via Digitalmars-d-learn
Is there any way to pass an unknown number of slices into a function? I'm trying to do something along the lines of: void func(T)(T[] args...) { //... } That wasn't working, so I tried using another generic type where T was already defined: void func(U)(U args...) if(is(U == T[]) {