develooper Front page | perl.perl6.users | Postings from October 2018

Re: augment again

Thread Previous | Thread Next
From:
Elizabeth Mattijsen
Date:
October 20, 2018 21:41
Subject:
Re: augment again
Message ID:
97CD1E44-3970-47BD-AF85-2D885DC2C9AA@wenzperl.nl


> On 20 Oct 2018, at 17:50, Joseph Brenner <doomvox@gmail.com> wrote:
> 
> By the way, I'd really like to know what the vertical bar is here in
> front of "CORE":
> 
>>  for (|CORE::) .grep({ .key eq .value.^name }) .map( *.value ) -> $class {
> 
> It's not the "any" junction, is it?  How would that make sense here?

I think it’s a case of superstitious parentheses and slipping.  It seems to work fine with just:

    for CORE:: .grep…

More generally: a prefix:<|> indicates slipping the given thing.  For instance:

    $ 6 'my @a = ^10; my @b = 10..^20; for @a, @b { say $_ }'
    [0 1 2 3 4 5 6 7 8 9]
    [10 11 12 13 14 15 16 17 18 19]

so it would just iterate twice.  A prefix:<|> would slip the arrays:

    $ 6 'my @a = ^10; my @b = 10..^20; for |@a, |@b { say $_ }'
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19

iterating over the elements of each array.

Liz
Thread Previous | Thread Next


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