Re: variable as subroutine?

2020-02-12 Thread Aureliano Guedes
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

Re: variable as subroutine?

2020-02-12 Thread Andy Bach
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

Re: variable as subroutine?

2020-02-12 Thread William Michels via perl6-users
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. > ---

Re: variable as subroutine?

2020-02-12 Thread Aureliano Guedes
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

Re: variable as subroutine?

2020-02-12 Thread Andy Bach
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

Re: variable as subroutine?

2020-02-11 Thread Aureliano Guedes
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 > ---

Re: variable as subroutine?

2020-02-11 Thread Andy Bach
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

Re: variable as subroutine?

2020-02-11 Thread Simon Proctor
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? >

Re: variable as subroutine?

2020-02-11 Thread Andy Bach
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

Re: variable as subroutine?

2020-02-11 Thread Simon Proctor
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

Re: variable as subroutine?

2020-02-10 Thread Marc Chantreux
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