Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

n-dim array generator

by jo37 (Deacon)
on Jun 16, 2020 at 19:54 UTC ( [id://11118149]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # arg_1 to arg_n specify size in dimension k,
    # last arg is a reference to a sub
    ...
        }
        $na;
    }
    
  2. or download this
    $ar = narray(3, sub {$_[0]});
    # [0, 1, 2]
    
    $mr = narray(3, 3, sub {$_[0] == $_[1] || 0});
    # [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
    
  3. or download this
    sub narray (&@);
    
    $ar = narray {$_[0]} 3;
    
  4. or download this
    sub narray (&@);
    sub narray (&@) {
    ...
    my $na = narray {"<@_>"} 3, 2
    # [['<0 0>', '<0 1>'], ['<1 0>', '<1 1>'], ['<2 0>', '<2 1>']]
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://11118149]
Approved by marto
Front-paged by LanX
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-25 17:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found