Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hello Monks,

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,

In reply to dynamic map "quadrant" indexing by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (5)
    As of 2020-05-25 06:23 GMT
    Find Nodes?
      Voting Booth?
      If programming languages were movie genres, Perl would be:

      Results (143 votes). Check out past polls.