On 03/13/2017 10:20 PM, Brandon Allbery wrote:
Just to be a little more clear about what is happening here:
Perl 5 tended to treat things as strings if you use them as strings, or
as numbers if you use them as numbers. Perl 6 is more strict about that,
but makes an exception for specifically num
Just to be a little more clear about what is happening here:
Perl 5 tended to treat things as strings if you use them as strings, or as
numbers if you use them as numbers. Perl 6 is more strict about that, but
makes an exception for specifically numbers and strings; if you have
noticed the class "
On 03/13/2017 09:16 PM, ToddAndMargo wrote:
What am I doing wrong now !?!?! :'( :'( :'(
#!/usr/bin/perl6
sub Test () {
my $f = $?FILE; say "\$\?FILE=<$f>";
my $g = $?FILE.IO.basename; say "\$\?FILE.IO.basename=<$g>";
( my $IAm = $?FILE ) ~~ s|.*"/"||; say "Regex \$IAm=<$IAm>";
What am I doing wrong now !?!?! :'( :'( :'(
#!/usr/bin/perl6
sub Test () {
my $f = $?FILE; say "\$\?FILE=<$f>";
my $g = $?FILE.IO.basename; say "\$\?FILE.IO.basename=<$g>";
( my $IAm = $?FILE ) ~~ s|.*"/"||; say "Regex \$IAm=<$IAm>";
# sub Test () { #`(Sub|58588296) ... }
Seems to me because the second '(' is not preceded by a space; it is '`('.
But if the second '(' was eg '` (', then the longest match would have
been picked and a ? would be necessary.
On Tuesday, March 14, 2017 11:21 AM, ToddAndMargo wrote:
On 03/13/2017 08:16 PM, ToddAndMargo wrote:
On 03
On 03/13/2017 08:16 PM, ToddAndMargo wrote:
On 03/13/2017 07:53 PM, yary wrote:
I think p6 regexes behave a bit like p5 regexes with the "x" flag turned
on, where whitespace can be added in for readability. To have literal
whitespace, put quotes around it. Like this (untested)
$x ~~ m/sub ' '
On 03/13/2017 07:53 PM, yary wrote:
I think p6 regexes behave a bit like p5 regexes with the "x" flag turned
on, where whitespace can be added in for readability. To have literal
whitespace, put quotes around it. Like this (untested)
$x ~~ m/sub ' ' (.*) ' ' \(/;
Now that was way to easy and
On 03/13/2017 07:58 PM, Brandon Allbery wrote:
There is actually a third issue in that spaces are *ignored* in regexes,
so you actually end up with $/[0] eq ' Test'. Use the <.ws> rule to
avoid this. (The leading dot prevents that whitespace from additionally
being captured as $/ which here would
There is actually a third issue in that spaces are *ignored* in regexes, so
you actually end up with $/[0] eq ' Test'. Use the <.ws> rule to avoid
this. (The leading dot prevents that whitespace from additionally being
captured as $/ which here would be pointless. You might also want one
before the
I think p6 regexes behave a bit like p5 regexes with the "x" flag turned
on, where whitespace can be added in for readability. To have literal
whitespace, put quotes around it. Like this (untested)
$x ~~ m/sub ' ' (.*) ' ' \(/;
You have two problems:
(1) matches start from 0, not 1.
(2) .* gobbles as much as possible (this is also true in Perl 5) so it
matches to the ) at the end of (Sub|63218616). As in Perl 5, you add a ? to
make it take the shortest match instead:
#!/usr/bin/perl6
my $x='sub Test () { #`(Sub|63218616
Hi All,
Just as soon as I think I understand it, a little
humility fall into my lap!
#!/usr/bin/perl6
my $x='sub Test () { #`(Sub|63218616) ... }';
$x ~~ m/sub (.*) \(/;
say "$x\n$1";
$ WhoTest2.pl6
Use of Nil in string context
in block at ./WhoTest2.pl6 line 4
sub Test () { #`(Sub|632186
On 03/13/2017 04:12 PM, ToddAndMargo wrote:
On 03/13/2017 02:06 PM, ToddAndMargo wrote:
Hi All,
$ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say "$x\n\$0=<$0>\n";'
Use of Nil in string context in block at -e line 1
ab12cd
$0=<>
With out the "q" in this, it works. I deliberately put
the "q
On 03/13/2017 02:06 PM, ToddAndMargo wrote:
Hi All,
$ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say "$x\n\$0=<$0>\n";'
Use of Nil in string context in block at -e line 1
ab12cd
$0=<>
With out the "q" in this, it works. I deliberately put
the "q" to see what would happen when a patter was
On 03/13/2017 04:03 PM, yary wrote:
On Mon, Mar 13, 2017 at 6:16 PM, ToddAndMargo mailto:toddandma...@zoho.com>> wrote:
So if it only catches some of them, it will still return false?
There is no catching some of them- either the pattern matches and all
are caught, or the pattern fails an
On Mon, Mar 13, 2017 at 6:16 PM, ToddAndMargo wrote:
> So if it only catches some of them, it will still return false?
There is no catching some of them- either the pattern matches and all are
caught, or the pattern fails and none are caught. If you can show us an
example of some matching, you'
On March 10, 2017 10:32:43 PM Theo van den Heuvel
wrote:
Not with me it doesn't.
my $TheValue = $?FILE.subst(/.* "/"/, "", :g);
sub sayfn is export { $TheValue.say }
Could something else be wrong here?
cheers,
Theo
ToddAndMargo schreef op 2017-03-10 22:10:
On 03/10/2017 09:53 AM, Timo Pa
On 03/13/2017 02:28 PM, Elizabeth Mattijsen wrote:
On 13 Mar 2017, at 22:20, ToddAndMargo wrote:
On 03/13/2017 02:11 PM, Elizabeth Mattijsen wrote:
On 13 Mar 2017, at 22:06, ToddAndMargo wrote:
Hi All,
$ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say "$x\n\$0=<$0>\n";'
Use of Nil in
> On 13 Mar 2017, at 22:20, ToddAndMargo wrote:
>
> On 03/13/2017 02:11 PM, Elizabeth Mattijsen wrote:
>>
>>> On 13 Mar 2017, at 22:06, ToddAndMargo wrote:
>>>
>>> Hi All,
>>>
>>> $ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say "$x\n\$0=<$0>\n";'
>>> Use of Nil in string context in block
On 03/13/2017 02:11 PM, Elizabeth Mattijsen wrote:
On 13 Mar 2017, at 22:06, ToddAndMargo wrote:
Hi All,
$ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say "$x\n\$0=<$0>\n";'
Use of Nil in string context in block at -e line 1
ab12cd
$0=<>
With out the "q" in this, it works. I deliberatel
Hi All,
I adore this feature of loops:
perl6 -e 'my @x=qw[a b z y];
for @x -> $a, $b { say "<$a> <$b>" };'
because I can preassign a names to "$_".
Question: in a pattern match such as:
perl6 -e 'my $x="ab12cd";
$x ~~ m/(ab)(12)(cd)/;
say "$x\n\$0=<$0>\t\$1=<$1>\t\$2=<$2>\n";'
> On 13 Mar 2017, at 22:06, ToddAndMargo wrote:
>
> Hi All,
>
> $ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say "$x\n\$0=<$0>\n";'
> Use of Nil in string context in block at -e line 1
> ab12cd
> $0=<>
>
> With out the "q" in this, it works. I deliberately put
> the "q" to see what would
Hi All,
$ perl6 -e 'my $x="ab12cd"; $x ~~ m/ab(1q2)cd/; say "$x\n\$0=<$0>\n";'
Use of Nil in string context in block at -e line 1
ab12cd
$0=<>
With out the "q" in this, it works. I deliberately put
the "q" to see what would happen when a patter was not
found.
Is there a way around the "use of
The == operator coerces to Numeric, so like:
> sub one-thing { return ("hi",) }
sub one-thing () { #`(Sub|93867233982256) ... }
> one-thing.Numeric
1
(mentioned in https://docs.perl6.org/routine/$EQUALS_SIGN$EQUALS_SIGN)
I think my does indeed do some fancy precidenting with the assignment.
--B
On 03/13/2017 01:16 AM, Elizabeth Mattijsen wrote:
On 13 Mar 2017, at 08:27, ToddAndMargo wrote:
Hi All,
What am I doing wrong here?
$ perl6 -e 'my $x="abc\(123\)def"; $x ~~ m/(abc\))(123)(\(def)/; say "$x\n\$0=<$0>
\$1=<$1> \$2=<$2>\n";'
Use of Nil in string context
in block at -e li
On Mon, Mar 13, 2017 at 12:37 PM, Will Coleda wrote:
> Works the same in Perl 6, and you can avoid the parens. Using helper
> subs that return one or two item lists, here's some sample code:
>
> $ perl6
> > sub one-thing { return ("hi",) }
> sub one-thing () { #`(Sub|140454852043936) ... }
> > 1
Works the same in Perl 6, and you can avoid the parens. Using helper
subs that return one or two item lists, here's some sample code:
$ perl6
> sub one-thing { return ("hi",) }
sub one-thing () { #`(Sub|140454852043936) ... }
> 1 == my $script = one-thing
True
> $script
(hi)
> sub two-things { r
In Perl 5, list assignment in scalar context evaluates to the number of
list elements on the right-hand side. That enables an idiom that I rather
like:
1 == (my ($script) = $page->find('//script'))
or die "Other than exactly one script element found";
Can a similar expression that avoi
Hi,
「gather」 should work. What version of Perl 6 are you using? (run perl6 -v)
I may be wrong, but I think the code should be:
my \golden= (1 + sqrt 5) ÷ 2;
my \fib = 1, 1, * + * ... ∞ ;
my \approx= gather for fib.rotor(2 => -1) { take .[1] ÷ .[0] };
my \distances = approx.map: (g
Hi,
I think you mean:
my \golden= ( 1 + sqrt 5 ) / 2;
best,
Theo
Marc Chantreux schreef op 2017-03-13 14:28:
hello,
i saw a math show with my son and we tried to use perl6
* to demonstrate the fact that the ratio between the terms
n and n-1 in the fibonnaci sequence gets closer to the
hello,
i saw a math show with my son and we tried to use perl6
* to demonstrate the fact that the ratio between the terms
n and n-1 in the fibonnaci sequence gets closer to the golden number
* let him know how awesome is perl6
so i wrote
my \golden= ( 1 / sqrt 5 ) / 2;
my \fib = (
$ perl6 -e 'my $x="abc(123)def"; say $x ~~ m/(abc)(\(123\))(def)/;'
-am
On 13.03.17 00:27, ToddAndMargo wrote:
> Hi All,
>
> What am I doing wrong here?
>
> $ perl6 -e 'my $x="abc\(123\)def"; $x ~~ m/(abc\))(123)(\(def)/; say
> "$x\n\$0=<$0> \$1=<$1> \$2=<$2>\n";'
>
> Use of Nil in string c
now we are at it, for readability perhaps instead of substitutes do,
my $thevalue = $?FILE.IO.basename;
Marcel
On March 10, 2017 10:32:43 PM Theo van den Heuvel
wrote:
Not with me it doesn't.
my $TheValue = $?FILE.subst(/.* "/"/, "", :g);
sub sayfn is export { $TheValue.say }
Could some
> On 13 Mar 2017, at 08:27, ToddAndMargo wrote:
>
> Hi All,
>
> What am I doing wrong here?
>
> $ perl6 -e 'my $x="abc\(123\)def"; $x ~~ m/(abc\))(123)(\(def)/; say
> "$x\n\$0=<$0> \$1=<$1> \$2=<$2>\n";'
>
> Use of Nil in string context
> in block at -e line 1
> Use of Nil in string cont
Hi All,
What am I doing wrong here?
$ perl6 -e 'my $x="abc\(123\)def"; $x ~~ m/(abc\))(123)(\(def)/; say
"$x\n\$0=<$0> \$1=<$1> \$2=<$2>\n";'
Use of Nil in string context
in block at -e line 1
Use of Nil in string context
in block at -e line 1
Use of Nil in string context
in block
35 matches
Mail list logo