With AoAs something like:
written as a template with the literals as documentation. After the not-finding and the not-thinking, I wrote a sub to walk AoAs and extract the references to the scalar elements. Doing it by hand, one might write:my $ar = [ [ 'HEAD_goes_here', 'BODY_here' ], [ 'FOOT', 'FOOT', 'FOOT', 'FOOT' ] ];
Its gist:my $scalars_flattened = [ \$ar->[0][0], \$ar->[0][1], \$ar->[1][0], \$ar->[1][1], \$ar->[1][2], \$ar->[1][3] ];
Fortunately only in testing did I find the less helpfully shaped templates like:my @flat = @{$_[0]}; while ( List::Util::any { 'ARRAY' eq ref $_ } @flat ) { @flat = map { 'ARRAY' eq ref $_ ? \(@$_) : \$_ } @flat; @flat = map { 'REF' eq ref $_ ? $$_ : $_ } @flat; }
I would die if I had one like that.$ar = [ 'HEAD', 'BODY', [ 'FOOT', 'FOOT', 'FOOT', 'FOOT'], ];
Be well,
rir
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: "Nonliteral literal" is just an expression.
by choroba (Cardinal) on Sep 24, 2019 at 10:04 UTC | |
by rir (Vicar) on Sep 24, 2019 at 21:30 UTC | |
by choroba (Cardinal) on Sep 25, 2019 at 08:27 UTC |
Back to
Meditations