1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
T[][] zip_longest2(T)(T[] a, T[]b){ T[][] res; if (a.length >= b.length){ swap(a,b); } T fillvalue = '-'; foreach(i, ref e; b) { writeln(i, e, fillvalue); if (i >= --a.length ) { res ~= [e, fillvalue]; } else { res~=[e,a[i]]; } } return res; }