digitalmars.D.learn - array walker
- Saaa (32/32) Jun 30 2009 I am currently approaching arrays in a absolute manner, like for setting...
I am currently approaching arrays in a absolute manner, like for setting a value: --- private template indexAssign(T: T[]) { void indexAssign(ref T array, BaseType!(T) value, int[] indices) { static if( is( typeof(array[0]) == typeof(value))) { array[indices[0]] = value; } else { indexAssign!(T)( array[indices[0]], value, indices[1..$]); } } } --- Maybe a more relative approach makes all these absolute templates obsolete, like: --- int[][][] array; int* walker; // what is the correct type to do something like this? walker = array; walker = right(walker,3); // [[],[],[]] walker = up(walker); // [[],[],[[]]] walker =right(walker,1); // [[],[],[[],[]]] walker =up(walker); // [[],[],[[],[[]]]] &walker = 6; // [[],[],[[],[[6]]]] --- How do people normally generate and access their arrays while parsing? Maybe after the parsing process?
Jun 30 2009