nt - unlike Perl5
>>>
>> Now I see. I din't know that. Thanks. I must study better Raku.
>>
>
> Hi Aureliano, watch about a minute of this Damian Conway video--where he
> shows the new Raku (Perl6) sigil table:
>
> https://youtu.be/Nq2HkAYbG5o?t=568
Wednesday, February 12, 2020 1:27 PM
To: Aureliano Guedes
Cc: Andy Bach ; perl6-users
Subject: Re: variable as subroutine?
On Wed, Feb 12, 2020 at 8:12 AM Aureliano Guedes
mailto:guedes.aureli...@gmail.com>> wrote:
On Wed, Feb 12, 2020 at 1:09 PM Andy Bach
mailto:andy_b...@wiwb.usco
a single element - unlike Perl5
>>
> Now I see. I din't know that. Thanks. I must study better Raku.
>
Hi Aureliano, watch about a minute of this Damian Conway video--where he
shows the new Raku (Perl6) sigil table:
https://youtu.be/Nq2HkAYbG5o?t=568
HTH, Bill.
> ---
t; as @a - raku doesn't swap sigils, so arrays always use @ even when they're
> being dereferenced (?) to a single element - unlike Perl5
>
Now I see. I din't know that. Thanks. I must study better Raku.
> --
> *From:* Aureliano Guedes
> *Sent:* Tuesday, Febru
uedes
Sent: Tuesday, February 11, 2020 7:00 PM
To: Andy Bach ; perl6-users
Subject: Re: variable as subroutine?
Sorry, I sent my answer just for you.
So, the problem is you didn't call the same var you had declared.
my $foo = * **2;
Then you call
foo(2).say
Missing the $
Try:
$foo(2).say
or
s
ls anymore, so it should be
> @a[0](2)
>
> maybe, pass the param, to the first bucket in @a which is holding a sub,
> so run it - works here
> > my @a = * **2;
> [{ ... }]
> > say @a[0](4);
> 16
>
> as does ".()"
> > say @a[0].(5);
> 25
> ---
From: Simon Proctor
Sent: Tuesday, February 11, 2020 9:27 AM
To: Andy Bach
Cc: perl6-users
Subject: Re: variable as subroutine?
The * * * call generates a WhateverCode block. This is expecting 2 arguments.
-> $x { $x * $x } is taking one argument.
The best document
submethod CALL-ME(|c){ 'called' }
> }
> my = A;
> say a(); # OUTPUT: «called»
>
> That second "postfix" operator, means
> say a.(); # also outputs "called"
>
> but what is the "pipe c" signature doing for the submethod?
>
my = A;
say a(); # OUTPUT: «called»
That second "postfix" operator, means
say a.(); # also outputs "called"
but what is the "pipe c" signature doing for the submethod?
From: Simon Proctor
Sent: Tuesday, February 11, 2020 3:17 AM
To: T
If you can store a subroutine in a variable then you can pass said
subroutine to another one as an argument.
This leads us into the joys of functional programming.
And you may have used it already and not even realised.
The .map and .grep methods (and .reduce and bunch of others) all expect a
hello ToddAndMargo,
> Can I declare a subroutine as a variable?
just use the callable sigil (https://docs.perl6.org/type/Callable).
those are 3 ways to write the same sub:
sub foo ($x) { $x * $x }
my = -> $x { $x * $x }
my = * * *;
regards,
marc
11 matches
Mail list logo