in reply to Re^2: n-dim array generator
in thread n-dim array generator

Sure, there are several ways to implement it. That's not what I'm actually interested in - from the usage point of view it doesn't matter too much. Such a piece of code is just not enough that would justify it's own module. If only any of these were available as an export!

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Replies are listed 'Best First'.
Re^4: n-dim array generator
by LanX (Saint) on Jun 17, 2020 at 15:16 UTC
    IMHO is the classic approach simple enough.

    Especially if you only want dim 1 and 2, I'd rather prefer combining map.

    > any of these were available as an export!

    You might want to have a look at List::MoreUtils or PDL and CPAN modules referencing them in "See Also" or in their dependencies..

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Re^4: n-dim array generator
by etj (Priest) on Apr 21, 2022 at 08:27 UTC
    The PDL function ndcoords looks like it does what you need.
    pdl> p ndcoords 3,3 [ [ [0 0] [1 0] [2 0] ] [ [0 1] [1 1] [2 1] ] [ [0 2] [1 2] [2 2] ] ]