Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
this is so embarassing. I feel this is easy, but somehow I'm too stupid to achieve it. Needed is a subroutine, that will print letter/number indices of map quadrants. Depending on the level (zoom):
&idx(1); # will spill out: A1 B1 C1 D1 &idx(2); # will spill out A1A1 A1B1 A1C1 A1D1 # B1A1 B1B1 B1C1 B1D1 # C1A1 C1B1 C1C1 C1D1 # D1A1 D1B1 D1C1 D1D1 &idx(3); # should do A1A1A1 A1A1B1 A1A1C1 A1A1D1 # A1B1A1 A1B1B1 A1B1C1 A1B1D1 # etc.
Any means of doing this iteratively failed miserably, probably a recursive solution would be best, but somehow I'm failing to get a grip on the numbers:
$lvl can be anything from 1 to n, which results in 4**$lvl return values, each value consisting of $lvl <char><digit> numbers. As you probably figured out, chars are always [A-D] and digits [1-4].
This probably wouldn't be used for $lvl > 6, but you never know so I wanted to go for a generic solution.
Do you have any idea HowTo?
Thanks a lot,
Marcel
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: dynamic map "quadrant" indexing
by tlm (Prior) on Aug 14, 2005 at 15:35 UTC | |
by ikegami (Patriarch) on Aug 14, 2005 at 17:07 UTC | |
by lidden (Curate) on Aug 14, 2005 at 19:51 UTC | |
Re: dynamic map "quadrant" indexing
by tlm (Prior) on Aug 14, 2005 at 14:46 UTC | |
Re: dynamic map "quadrant" indexing
by Anonymous Monk on Aug 14, 2005 at 10:20 UTC | |
by Anonymous Monk on Aug 14, 2005 at 13:42 UTC |