Re: array(0, {800,600}) is easier.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Lucius,

I wouldn't be surprised if I am woefully misunderstanding something really
basic, but it seems to me that neither your "repeat" example nor your array
function yield the 8x10 array you want.  Doesn't  "repeat(repeat(0,10), 8)"
give  a sequence of TEN zeroes, repeated 8 times, instead of the 8 zeroes
repeated 10 times you show in your example?

Ditto for your array function when I run it & display it with smart_print.
Looks to me like "for A = length(dimensions) to 1 by -1 do" should be "for A
= 1 to length(dimensions) do" ?

Dan Moyer


-----Original Message-----
From: Lucius L. Hilley III


>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 |
>+----------+-----------------------------+

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu