On 2020-08-30 08:16, yary wrote:
Looking up https://docs.raku.org/routine/lines shows a Table of Contents
with
class Cool
(Cool) routine lines
class Supply
(Supply) method lines
class Str
(Str) routine lines
class IO::CatHandle
(IO::CatHandle) method lines
I like your script, Bruce. And you are quite correct--my code seems to
work just fine without ".words":
~$ raku -e 'say @*ARGS.grep(*.Rat).sum;'
Best, Bill.
On Mon, Aug 31, 2020 at 1:42 PM Bruce Gray wrote:
>
> Bill,
>
> You were correct that `!=== 0` is redundant in the original code,
On 2020-08-30 08:16, yary wrote:
Expanding on how to read the docs & signature a bit, from Tobias
You confuse two methods that have the same name "lines". One of them,
which exists in the IO::Path class, has a :chomp argument. The other,
on IO::Handle does not.
On 2020-08-31 18:54, William Michels via perl6-users wrote:
On Mon, Aug 31, 2020 at 6:07 PM ToddAndMargo via perl6-users
wrote:
On 2020-08-31 17:21, yary wrote:
First part of my previous email on this thread! Re-read this bit
First, you were looking at the docs for Path's "lines", but you
On Mon, Aug 31, 2020 at 6:07 PM ToddAndMargo via perl6-users
wrote:
>
> On 2020-08-31 17:21, yary wrote:
> > First part of my previous email on this thread! Re-read this bit
> >
> >> First, you were looking at the docs for Path's "lines", but you are
> >> using a string "lines" and those docs say
On 2020-08-31 17:21, yary wrote:
First part of my previous email on this thread! Re-read this bit
First, you were looking at the docs for Path's "lines", but you are
using a string "lines" and those docs say
multi method lines(Str:D: $limit, :$chomp = True)
multi method lines(Str:D: :$chomp
Nope $_ is the "default topic" if you want to use the jargon. It has a
name, the underscore character.
$ is a nameless variable, jargon is "anonymous scalar"
$_ is different specialness from $
-y
On Mon, Aug 31, 2020 at 5:13 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:
> On
First part of my previous email on this thread! Re-read this bit
> First, you were looking at the docs for Path's "lines", but you are
> using a string "lines" and those docs say
>
> multi method lines(Str:D: $limit, :$chomp = True)
> multi method lines(Str:D: :$chomp = True)
>
> Files get
On 2020-08-31 17:03, yary wrote:
anonymous variable
Would be safe thinking it had the same properties as `$_`?
On 2020-08-30 08:42, yary wrote:
You were close!
First, you were looking at the docs for Path's "lines", but you are
using a string "lines" and those docs say
multi method lines(Str:D: $limit, :$chomp = True)
multi method lines(Str:D: :$chomp = True)
Files get "nl-in" due to the special
I like this better for alpha counter
raku -e "for (1..4) { say (BEGIN $ = 'AAA')++ }"
with BEGIN, the assignment of AAA happens once. With the earlier ||= it
checks each time through the loop.
-y
On Mon, Aug 31, 2020 at 5:03 PM yary wrote:
> Not even a reset- every time there's a $ by itself
Depends where in your code the $++ is.
It may play as global or as local.
raku -e 'for 1..3 {say $++}; say $++'
On Mon, Aug 31, 2020 at 9:03 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:
>
> > adn
>
> fixed
>
--
Aureliano Guedes
skype: aureliano.guedes
contato: (11)
Not even a reset- every time there's a $ by itself it is a new/different
anonymous variable. So it is only useful where it is never referred to
anywhere else.
$ raku -e "for (1..4) { say $++, ' , ', ++$; say 'again- ',$;}"
0 , 1
again- (Any)
1 , 2
again- (Any)
2 , 3
again- (Any)
3 , 4
adn
fixed
On 2020-08-31 16:57, ToddAndMargo via perl6-users wrote:
On 2020-08-31 16:53, ToddAndMargo via perl6-users wrote:
On Mon, Aug 31, 2020, 4:20 PM ToddAndMargo via perl6-users
mailto:perl6-us...@perl.org>> wrote:
On 2020-08-31 05:53, Brian Duggan wrote:
> On Monday, August 24, Curt
On 2020-08-31 16:53, ToddAndMargo via perl6-users wrote:
On Mon, Aug 31, 2020, 4:20 PM ToddAndMargo via perl6-users
mailto:perl6-us...@perl.org>> wrote:
On 2020-08-31 05:53, Brian Duggan wrote:
> On Monday, August 24, Curt Tilmes wrote:
>> $ cat Lines.txt | raku -e '.say for
On Mon, Aug 31, 2020, 4:20 PM ToddAndMargo via perl6-users
mailto:perl6-us...@perl.org>> wrote:
On 2020-08-31 05:53, Brian Duggan wrote:
> On Monday, August 24, Curt Tilmes wrote:
>> $ cat Lines.txt | raku -e '.say for lines()[3,2,5]'
>
> The -n flag is an option here
Answering my own question, the operator sets the type of $. That's what
gradual typing is all about!
$ seq 5 | raku -ne "say $++"
0
1
2
3
4
$ seq 5 | raku -ne "say $ ~= 'Hi' "
Hi
HiHi
HiHiHi
HiHiHiHi
HiHiHiHiHi
$ seq 5 | raku -ne "say $++, $ ~= ' Hi' "
0 Hi
1 Hi Hi
2 Hi Hi Hi
3 Hi
Basically :
$ raku -e 'my $a = 1; say ++$a; say $a'
2
2
$ raku -e 'my $a = 1; say $a++; say $a'
1
2
On Mon, Aug 31, 2020 at 8:36 PM yary wrote:
> $ by itself is an anonymous variable, putting ++ after starts it at 0 (hmm
> or nil?) and increments up.
>
> By putting the plus plus first, ++$, it
$ by itself is an anonymous variable, putting ++ after starts it at 0 (hmm
or nil?) and increments up.
By putting the plus plus first, ++$, it will start at 1, thanks to
pre-increment versus post increment
On Mon, Aug 31, 2020, 4:20 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:
On 2020-08-31 05:53, Brian Duggan wrote:
On Monday, August 24, Curt Tilmes wrote:
$ cat Lines.txt | raku -e '.say for lines()[3,2,5]'
The -n flag is an option here too:
raku -ne '.say if $++ == 3|2|5' Lines.txt
Brian
Hi Bill,
Works beatifically! And no bash pipe!
$ raku -ne '.say
Bill,
You were correct that `!=== 0` is redundant in the original code, because a
numeric will be checked for zero-versus-not-zero in Boolean context, and
because `==` and `===` should mean the same thing when comparing a bare numeric
value.
In your latest version, I want to point out that
Sorry Radhakrishnan, for mis-spelling your name in my last post. --B.
On Mon, Aug 31, 2020 at 1:02 PM William Michels wrote:
>
> Very nice, Bruce and Daniel!
>
> I continued to hack on Rahakrishnan's code, then realized I could try
> using Bruce's grep() call as a filter:
>
> ~$ raku -e
Daniel’s solution taught me to not ignore the simple numeric coercion operator:
`+`.
I was trying to improve version just now, using `0 + $_` in a grep, and got
hung up on the error thrown on failed numeric conversion.
I ended up with:
.grep: { try 0 + $_ };
Which does work, and might
Very nice, Bruce and Daniel!
I continued to hack on Rahakrishnan's code, then realized I could try
using Bruce's grep() call as a filter:
~$ raku -e '@*ARGS.words.grep(*.Rat).sum.say;' 100 200 300 apples
400oranges 2kilos 18.7876 500 grams14 10stars10 sun100moon 77
1195.7876
HTH, Bill.
On
I like Bruce's Regex-based approach.
Here's how I'd probably approach the problem:
raku -e 'say [+] @*ARGS.grep(+*)' 0 100 200 300 apples 400oranges 2kilos
18.7876 500 grams14 10stars10 sun100moon 77
August 31, 2020 2:28 PM, "Bruce Gray" wrote:
> my $is_a_number = / ^ \d+ [ '.' \d* ]? $ /;
>
my $is_a_number = / ^ \d+ [ '.' \d* ]? $ /;
my $sum = @*ARGS.grep($is_a_number).sum;
say $sum;
—
Hope this helps,
Bruce Gray (Util of PerlMonks)
> On Aug 31, 2020, at 12:22 PM, William Michels via perl6-users
> wrote:
>
> I think it looks very good, Radhakrishnan! Presumably you are happy
I think it looks very good, Radhakrishnan! Presumably you are happy
with the sum 1195.7876?
~$ raku -e 'for @*ARGS {.say if ($_.Int // 0) };' 0 100 200 300 apples
400oranges 2kilos 18.7876 500 grams14 10stars10 sun100moon 77
100
200
300
18.7876
500
77
I'm still mulling over whether or not the
> Not getting back line #11 with
perl -ne 'print if $. =~ /\b[3 2 5 11]\b/' test_lines.txt
Right, as the char class contains , 1, 2, 3 and 5. I guess alternatives
perl -ne 'print if $. =~ /\b(1|5|3|11)\b/' /tmp/lines.txt
line: 1
line: 3
line: 5
line: 11
From:
Please see the following script that checks for type and sums up only the
numbers passed as arguments to the script in the command line. I would be
grateful if any improvement or furtherance to this script is offered.
Thank you.
#
# sums the numbers given in command line arguments and prints
#
Thanks Yary! So that means Brian's answer in Raku can use the
smartmatch operator instead of the "==". Good to know!
~$ raku -ne '.say if ++$ ~~ 3|5|11' test_lines.txt
Line 3
Line 5
Line 11
On Mon, Aug 31, 2020 at 8:47 AM yary wrote:
>
> Aww don't you remember Raku's earliest(?) contribution to
Aww don't you remember Raku's earliest(?) contribution to Perl? I was so
happy when this arrived, and sad over its subsequent neglect
perl -ne 'no warnings "experimental"; print if $. ~~ [3,5,11]' line0-10.txt
-y
On Mon, Aug 31, 2020 at 8:28 AM William Michels via perl6-users <
How would P5 handle line numbers > 10 ? Not getting back line #11 with
the P5 examples below:
$ raku -ne '.say if ++$ == 3|2|5|11' test_lines.txt
Line 2
Line 3
Line 5
Line 11
~$ perl -ne 'print if $. =~ /\b[3 2 5 11]\b/' test_lines.txt
Line 1
Line 2
Line 3
Line 5
~$ perl -ne 'print if $. =~
On Monday, August 31, Andy Bach wrote:
> > raku -ne '.say if $++ == 3|2|5' Lines.txt
>
> OT, maybe, but is
> perl -ne 'print if $. =~ /\b[325]\b/' Lines.txt
>
> or
> perl -ne 'print if $c++ =~ /\b[436]\b/' Lines.txt
>
> the best you can do in P5?
I can't think of anything better :-)
Brian
> raku -ne '.say if $++ == 3|2|5' Lines.txt
OT, maybe, but is
perl -ne 'print if $. =~ /\b[325]\b/' Lines.txt
or
perl -ne 'print if $c++ =~ /\b[436]\b/' Lines.txt
the best you can do in P5?
a
Andy Bach, BS, MSCMECFA
Systems Mangler
Internet:
So I guess I got included on this as the resident language professor :-)
(although I probably should subscribe to p6 users at some point) I didn't see
the whole thread in the e-mail I got copied in on, so apologizes if I repeat
much.
I'll spare everyone all the linguistic details, but suffice
On Monday, August 24, Curt Tilmes wrote:
> $ cat Lines.txt | raku -e '.say for lines()[3,2,5]'
The -n flag is an option here too:
raku -ne '.say if $++ == 3|2|5' Lines.txt
Brian
Hello *,
I was wondering whether there's a way to tell that a section of pod6 should
be rendered only by a specific renderer.
My problem is that I want to show a figure in a README.md and I'm using
App::MI6, which builds the README.md file from the pod6 documentation in
the module file.
As far
38 matches
Mail list logo