RakudoStar-2020.05 just hit

2020-05-25 Thread ToddAndMargo via perl6-users

Hot off the presses:

RakudoStar-2020.05.1.01-win-x86_64-(JIT).msi

:-)


Re: I do not understand method":"

2020-05-25 Thread Brad Gilbert
A lambda is a function that doesn't have a name, or a location.

my $var =  *.raku();

say $var.( Date.today );
# Date.new(2020,5,25)

The long way to write that would be:

my $var = anon sub ( $_ ) { .raku() };

So this is passing in a function to sort, to calculate the value that is to
be sorted with:

<5 2 1 33 22>.sort( *.Version )

sub call-Version ( $_ ) { .Version }
<5 2 1 33 22>.sort(  );

What sort does in this case is call .Version on each of the values to be
sorted, and sorts it based on those values.

So it is something like the following:

my @to-sort;
for <5 2 1 33 22> {
   push @to-sort, [.Version, .self]
}

my @sorted = @to-sort.sort();

my @result;
for @sorted {
  push @result, .[1]
}

say @result

---

Note that the following two lines are identical.

<5 2 1 33 22>.sort.Version
<5 2 1 33 22>.sort( ).Version( )

Which sorts using the default sort.
The result is a Seq.
Then it tries to call a method named Version on that Seq.

On Mon, May 25, 2020 at 4:41 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> >> On Mon, May 25, 2020 at 1:24 PM ToddAndMargo via perl6-users
> >> mailto:perl6-us...@perl.org>> wrote:
> >>
> >> Hi All,
> >>
> >> Looking at the following:
> >>
> >>   > my @things = .sort: *.Version;
> dd
> >> @things; for @things {say $_;}
> >>
> >> Array @things = ["a1b33", "a1", "a2rc2", "a2.3", "a5.1", "b1a23"]
> >>
> >> a1b33
> >> a1
> >> a2rc2
> >> a2.3
> >> a5.1
> >> b1a23
> >>
> >> Other than not quite getting the alpha, beta, and
> >> release candidate thing down, I do not understand:
> >>
> >> .sort: *.Version
> >>
> >> 1) What does the `:` do?
> >>
> >> 2) Why the space?
> >>
> >> 3) What does the `*` do?
> >>
> >> 4) Is the dot before Version mean something other
> >> than .Version being a method?
> >>
> >> Yours in confusion,
> >> -T
> >>
>
> On 2020-05-25 14:00, Brad Gilbert wrote:
> >
> > In the following the 「:」 makes it so you don't need parenthesis
> >
> >  (…).sort: …
> >
> >  (…).sort(…)
> >
> > The reason there needs to be a space is so it isn't confused for an
> adverb.
> >
> > 「*.Version」 is a method call turned into a lambda.
> > Basically it creates a lambda where the only thing it does is call a
> > method named 「Version」
> >
> > A 「*」 where a term is expected is an instance of Whatever.
> >
> > If you use that with an operator it becomes a WhateverCode lambda.
> >
> >  sub say-the-type ( $_ ) {
> >say .^name
> >  }
> >
> >  say-the-type  *;  # Whatever
> >
> >  say -the-type *.method; # WhateverCode
> >
> >
>
>
> Hi Brad,
>
> Thank you!
>
> So the same as
>  > my @things = <5 2 1 33 22>.sort( *.Version )
>  [1 2 5 22 33]
>
>
> Why don't these two work?  Or at least give the
> wrong answer.  I thought Version was a method.
>
>  > my @things = <5 2 1 33 22>.sort.Version
> No such method 'Version' for invocant of type 'Seq'
>in block  at  line 1
>
>  > my @things = <5 2 1 33 22>.Version.sort
> No such method 'Version' for invocant of type 'List'
>in block  at  line 1
>
>
> What is a "lambda" λ?
>
> -T
>


Re: I do not understand method":"

2020-05-25 Thread ToddAndMargo via perl6-users
On Mon, May 25, 2020 at 1:24 PM ToddAndMargo via perl6-users 
mailto:perl6-us...@perl.org>> wrote:


Hi All,

Looking at the following:

  > my @things = .sort: *.Version; dd
@things; for @things {say $_;}

Array @things = ["a1b33", "a1", "a2rc2", "a2.3", "a5.1", "b1a23"]

a1b33
a1
a2rc2
a2.3
a5.1
b1a23

Other than not quite getting the alpha, beta, and
release candidate thing down, I do not understand:

.sort: *.Version

1) What does the `:` do?

2) Why the space?

3) What does the `*` do?

4) Is the dot before Version mean something other
than .Version being a method?

Yours in confusion,
-T



On 2020-05-25 14:00, Brad Gilbert wrote:


In the following the 「:」 makes it so you don't need parenthesis

     (…).sort: …

     (…).sort(…)

The reason there needs to be a space is so it isn't confused for an adverb.

「*.Version」 is a method call turned into a lambda.
Basically it creates a lambda where the only thing it does is call a 
method named 「Version」


A 「*」 where a term is expected is an instance of Whatever.

If you use that with an operator it becomes a WhateverCode lambda.

     sub say-the-type ( $_ ) {
       say .^name
     }

     say-the-type  *;  # Whatever

     say -the-type *.method; # WhateverCode





Hi Brad,

Thank you!

So the same as
> my @things = <5 2 1 33 22>.sort( *.Version )
[1 2 5 22 33]


Why don't these two work?  Or at least give the
wrong answer.  I thought Version was a method.

> my @things = <5 2 1 33 22>.sort.Version
No such method 'Version' for invocant of type 'Seq'
  in block  at  line 1

> my @things = <5 2 1 33 22>.Version.sort
No such method 'Version' for invocant of type 'List'
  in block  at  line 1


What is a "lambda" λ?

-T


Regexps using 'after' and 'before' like ^ and $

2020-05-25 Thread Joseph Brenner
Given this string:
   my $str = "Romp romp ROMP";

We can match just the first or last by using the usual pinning
features, '^' or '$':

   say $str ~~ m:i:g/^romp/;   ## (「Romp」)
   say $str ~~ m:i:g/romp$/;   ## (「ROMP」)

Moritz Lenz (Section 3.8 of 'Parsing', p32) makes the point you
can use 'after' to do something like '^' pinning:

   say $str ~~ m:i:g/  romp /;   ## (「Romp」)

That makes sense:  the BOL is "not after any character"
So: I wondered if there was a way to use 'before' to do
something like '$' pinning:

  say $str ~~ m:i:g/ romp  /;  ## (「Romp」 「romp」)

That was unexpected: it filters out the one I was trying to
match for, though the logic seemed reasonable: the EOL is "not
before any character".

What if we flip this and do a positive before match?

  say $str ~~ m:i:g/ romp  /;  ## (「Romp」 「romp」)

That does exactly the same thing, but here the logic makes
sense to me: the first two are "before some character",
but the last one isn't.


Re: I do not understand method":"

2020-05-25 Thread Brad Gilbert
In the following the 「:」 makes it so you don't need parenthesis

(…).sort: …

(…).sort(…)

The reason there needs to be a space is so it isn't confused for an adverb.

「*.Version」 is a method call turned into a lambda.
Basically it creates a lambda where the only thing it does is call a method
named 「Version」

A 「*」 where a term is expected is an instance of Whatever.

If you use that with an operator it becomes a WhateverCode lambda.

sub say-the-type ( $_ ) {
  say .^name
}

say-the-type  *;  # Whatever

say -the-type *.method; # WhateverCode


On Mon, May 25, 2020 at 1:24 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Hi All,
>
> Looking at the following:
>
>  > my @things = .sort: *.Version; dd
> @things; for @things {say $_;}
>
> Array @things = ["a1b33", "a1", "a2rc2", "a2.3", "a5.1", "b1a23"]
>
> a1b33
> a1
> a2rc2
> a2.3
> a5.1
> b1a23
>
> Other than not quite getting the alpha, beta, and
> release candidate thing down, I do not understand:
>
> .sort: *.Version
>
> 1) What does the `:` do?
>
> 2) Why the space?
>
> 3) What does the `*` do?
>
> 4) Is the dot before Version mean something other
> than .Version being a method?
>
> Yours in confusion,
> -T
>


I do not understand method":"

2020-05-25 Thread ToddAndMargo via perl6-users

Hi All,

Looking at the following:

> my @things = .sort: *.Version; dd 
@things; for @things {say $_;}


Array @things = ["a1b33", "a1", "a2rc2", "a2.3", "a5.1", "b1a23"]

a1b33
a1
a2rc2
a2.3
a5.1
b1a23

Other than not quite getting the alpha, beta, and
release candidate thing down, I do not understand:

.sort: *.Version

1) What does the `:` do?

2) Why the space?

3) What does the `*` do?

4) Is the dot before Version mean something other
than .Version being a method?

Yours in confusion,
-T