develooper Front page | perl.perl6.users | Postings from April 2020

Re: unflattering flat

Thread Previous
From:
Larry Wall
Date:
April 5, 2020 00:34
Subject:
Re: unflattering flat
Message ID:
20200405003432.GA1972@wall.org
Oh, you wanna go deep?  Why stop at 10 levels?

    say gather %hash-with-arrays.values.deepmap: { .take }

No .flat needed, even.

Larry

On Sat, Apr 04, 2020 at 10:59:36PM +0100, Ralph Mellor wrote:
: [**] will be a wonderful thing when it's implemented.
: 
: In the meantime, you could maybe use this as a hack that works to 10
: levels deep:
: 
: my %hash-with-arrays = a => [1,2], b => [3,4];
: sub postfix:<[**]> ($arg) { $arg[*;*;*;*;*;*;*;*;*;*]}
: say %hash-with-arrays.values[**].flat # (1 2 3 4)

: 
: On Sat, Apr 4, 2020 at 7:46 PM Larry Wall <larry@wall.org> wrote:
: >
: > You can also do a hyper descalarize if you're into that sort of thing:
: >
: >     %hash-with-arrays.values蒜].flat
: >
: > Larry

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About