Front page | perl.perl6.users |
Postings from April 2020
unflattering flat
Thread Next
From:
Konrad Bucheli via perl6-users
Date:
April 4, 2020 04:40
Subject:
unflattering flat
Message ID:
VI1PR05MB56776881525FD279E1C9B071EDC60@VI1PR05MB5677.eurprd05.prod.outlook.com
Dear Raku programmers
I have a hash with arrays as value. Out of that I wanted to get a flat list with all the entries in the value arrays. My first intuitive attempt was to use flat, but somehow that only works with an additional map step:
$ raku
To exit type 'exit' or '^D'
> my %hash-with-arrays = a => [1,2], b => [2,3]
{a => [1 2], b => [2 3]}
> %hash-with-arrays.values.flat
([2 3] [1 2])
> %hash-with-arrays.values>>.map({$_})
((2 3) (1 2))
> %hash-with-arrays.values>>.map({$_}).flat
(2 3 1 2)
>
$ raku -v
This is Rakudo version 2020.02 built on MoarVM version 2020.02
implementing Raku 6.d.
$
How is that explained?
Cheers
Konrad
Thread Next
-
unflattering flat
by Konrad Bucheli via perl6-users