From:

Date:

July 14, 2021 19:58Subject:

Re: [naive] hash assingmentMessage ID:

CAG9gabS5pJfdDtFEq0GZnLhwBMKAV39=Z7QE0vUUgcpf0FyL4g@mail.gmail.comthank It is now more clear. And I like this notation |%a<column1> ==> map({.sqrt}); less is more sometimes On Wed, Jul 14, 2021 at 4:41 PM Daniel Sockwell <daniel@codesections.com> wrote: > To expand slightly on what Clifton said, the reason that > > > %a<column3> = %a<column1>.map: { .sqrt }; > > # (1 1.4142135623730951 1.7320508075688772 2 2.23606797749979) > > does what you mean but > > > %a{'column1'} ==> map( { .sqrt } ) > > # (2.23606797749979) > > does not is that the method .map maps over *each item* in the Array, > whereas > ==> map maps over the Array as *one collection*. When taking the square > root, > an Array needs to be treated as an number, which for Raku means treating > it as > a count of how many elements it has (i.e., its length). > > So `%a{'column1'} ==> map({.sqrt})` is the same as > `%a{'column1'}.elems.map({.sqrt})` > > If want to map over each item in the Array when using the ==> operator, > you need to > slip the items out of the Array before feeding them on. You can do that > with either > of the following (equivalent) lines: > > > %a{'column1'}.Slip ==> map({.sqrt}); > > |%a{'column1>'}==> map({.sqrt}); > > (Also, you may already know this, but when the keys of your hash are > strings, you > can write %a<column1> instead of %a{'column1'} ) > > Hope that helps! > > â€“codesections > -- Aureliano Guedes skype: aureliano.guedes contato: (11) 94292-6110 whatsapp +5511942926110Thread Previous | Thread Next

- [naive] hash assingment by Aureliano Guedes
- Re: [naive] hash assingment by Marcel Timmerman
- Re: [naive] hash assingment by Aureliano Guedes
- Re: [naive] hash assingment by Daniel Sockwell
- Re: [naive] hash assingment by Patrick R. Michaud
**Re: [naive] hash assingment**by Aureliano Guedes- Re: [naive] hash assingment by Brad Gilbert
- Re: [naive] hash assingment by Vadim Belman
- Re: [naive] hash assingment by William Michels via perl6-users
- Re: [naive] hash assingment by Clifton Wood
- Re: [naive] hash assingment by Aureliano Guedes
- Re: [naive] hash assingment by JJ Merelo

nntp.perl.org: Perl Programming lists via nntp and http.

Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About