Re: slurpy hash signatures

2021-04-20 Thread Joseph Brenner
Ralph Mellor wrote: > Joseph Brenner wrote: > > > Before I get started here, a small point about defining hashes. > > There are various ways that work: > > > >my %h1 = ( 'ha' => 1, 'ho' => 2, 'hum' => 3 ); > >my %h2 = ( ha => 1, ho => 2, hum => 3 ); > >my %h3 = ha => 1, ho =>

Re: gather take eager syntax

2021-04-20 Thread Ralph Mellor
You've gotten a pile of great answers. :) I'll add another to the pile, but omit explanation. say % = ["foo" => "bar"], "baz" => 42; # {foo bar => baz => 42} say % = ["foo" => "bar"]; # {foo => bar} say % = ["foo" => "bar"],; # Odd number ... Only saw: $[:foo("bar")

Re: gather take eager syntax

2021-04-20 Thread William Michels via perl6-users
I can get this to work (in the Raku REPL): > my %h = gather { take("foo" => 1).eager} {foo => 1} > If I imagine that ":eager" is an adverb modifying take(), it fails: > my %h = gather { take(:eager) "foo" => 1} ===SORRY!=== Error while compiling: Two terms in a row --> my %h = gather { take(

Re: gather take eager syntax

2021-04-20 Thread Bruce Gray
> On Apr 20, 2021, at 12:39 AM, Norman Gaywood wrote: > > Hi, I can't figure out why the last line here is failing. > Version 2020.07 > > $ raku > To exit type 'exit' or '^D' > > my %h = gather { take "foo"=>1; take "bar"=>2;} > {bar => 2, foo => 1} > > my %h = gather { take "foo"=>1} > {foo =

Re: gather take eager syntax

2021-04-20 Thread Brad Gilbert
A Hash either takes some number of pairs my %h = a => 1, b => 2; or an even number of elements, which become key value pairs my %h = 'a', 1, 'b', 2; `eager` returns an eager Sequence/List etc (eager a => 1).raku # (:a(1),) A Sequence/List is itself a thing. Which means that it can

Re: gather take eager syntax

2021-04-20 Thread Richard Hainsworth
The 'take' is creating a Pair, which is one thing, whilst when creating a hash, you need two things: the key and the value. The gather adds extra complexity by creating a list, which is also one thing. But you could flatten the list into the list of things by using |. So `my %h = gather { tak