array walker
Saaa
empty at needmail.com
Tue Jun 30 17:50:25 PDT 2009
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?
More information about the Digitalmars-d-learn
mailing list