Re: How to push a hash on an array without flattening it to Pairs?

2015-09-26 Thread Aristotle Pagaltzis
* Elizabeth Mattijsen [2015-09-26 13:20]: > The flattening will not be done if more than one argument is specified: > > $ 6 'my %h = a => 42, b => 666; my @a = %h,%h; dd @a' > Array @a = [{:a(42), :b(666)}, {:a(42), :b(666)}] > > > This is the same behaviour as with for: > > $ 6

Re: How to push a hash on an array without flattening it to Pairs?

2015-09-26 Thread Tobias Leich
Itemization helps: m: my %h = x => 6, y => 7; my @a = $%h; say @a[0] rakudo-moar 0132b6: OUTPUT«x => 6, y => 7␤» m: my %h = x => 6, y => 7; my @a; @a.push: $%h; say @a[0] rakudo-moar 0132b6: OUTPUT«x => 6, y => 7␤» Am 26.09.2015 um 07:58 schrieb Gabor Szabo: > In the first two cases the hash

Re: How to push a hash on an array without flattening it to Pairs?

2015-09-26 Thread Aristotle Pagaltzis
* Moritz Lenz [2015-09-26 09:40]: > A trailing comma helps: > > my %h = a => 1, b => 2; > my @a = %h, ; > say @a.perl;# [{:a(1), :b(2)},] I think I understand why, but wow, that’s not reasonable. Is there really no better way to avoid the flattening? Even Perl 5 is nicer

Re: How to push a hash on an array without flattening it to Pairs?

2015-09-26 Thread Elizabeth Mattijsen
> On 26 Sep 2015, at 13:09, Aristotle Pagaltzis wrote: > * Moritz Lenz [2015-09-26 09:40]: >> A trailing comma helps: >> >> my %h = a => 1, b => 2; >> my @a = %h, ; >> say @a.perl;# [{:a(1), :b(2)},] > > I think I understand why, but wow, that’s not

Re: How to push a hash on an array without flattening it to Pairs?

2015-09-26 Thread Moritz Lenz
On 09/26/2015 02:26 PM, Aristotle Pagaltzis wrote: > Now of course I must ask – is there an opposite also? I.e. when writing > a list, is there a way I can say “do flatten this item?” Yes, that's what type Slip is for: http://doc.perl6.org/type/Slip It's useful for returning more than one list

Re: How to push a hash on an array without flattening it to Pairs?

2015-09-26 Thread Elizabeth Mattijsen
> On 26 Sep 2015, at 14:26, Aristotle Pagaltzis wrote: > * Elizabeth Mattijsen [2015-09-26 13:20]: >> There is: you just need to itemize the hash, e.g. by prefixing it with $ >> >> $ 6 'my %h = a => 42, b => 666; my @a = $%h; dd @a' >> Array @a = [{:a(42),

How to push a hash on an array without flattening it to Pairs?

2015-09-25 Thread Gabor Szabo
In the first two cases the hash was converted to Pairs before assigning to the array. Only the third case gave what I hoped for. How can I push a hash onto an array as a single entity? use v6; my %h = x => 6, y => 7; say %h.perl; # {:x(6), :y(7)} my @a = %h; say @a.elems; # say @a[0];