Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: dynamic map "quadrant" indexing

by tlm (Prior)
on Aug 14, 2005 at 14:46 UTC ( #483699=note: print w/replies, xml ) Need Help??


in reply to dynamic map "quadrant" indexing

Update: I think the glob-based solution in my other reply is the way to go; I wish I'd thought of it first. Ignore this one.


Here's a recursive solution:

use strict; use warnings; my $lvl = shift || 2; my @indices = indices( $lvl ); print "$_\n" for @indices; sub indices { my $lvl = shift; die if $lvl < 0; return $lvl ? map make_indices( $_ ), indices( $lvl - 1 ) : ( '' ); } sub make_indices { my $base = shift; return map "$base${_}1", 'A' .. 'D'; }

the lowliest monk

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://483699]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2020-05-29 14:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (169 votes). Check out past polls.

    Notices?