array(0, {800,600}) is easier.
- Posted by "Lucius L. Hilley III" <lhilley at CDC.NET> May 10, 2000
- 565 views
Assume that you want a sequence of 8x10. Maybe it is a sprite or FONT. :) IE: sequence s s = { {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0} } --or currently we may use: s = repeat(repeat(0,10), 8) Notice that the dimension definitions are reversed to get the desired arrangement. This can easily lead to programming confusion. function array(object obj, sequence dimensions) object x x = obj for A = length(dimensions) to 1 by -1 do x = repeat(x, dimensions[A]) end for return x end function now you can use: s = array(0, {8,10}) OR what the subject states. I know this is simple just a simple little thing that any of you can do at will when needed. I think it would make a nice addition to misc.e A sort of tool to make some types of programming easier. In the mean time I will build and use it when needed. OH, I also think that array(0, {8, 10}) is more readable because of the declaration isn't reversed. Lucius L. Hilley III lhilley at cdc.net +----------+--------------+--------------+ | Hollow | ICQ: 9638898 | AIM: LLHIII | | Horse +--------------+--------------+ | Software | http://www.cdc.net/~lhilley | +----------+-----------------------------+