On Mon, Sep 23, 2019 at 11:34:14PM -0500, Brad Gilbert wrote:
> You can create your own $*ARGFILES.
>
> sub MAIN ( +@ARGS ){
> my $*ARGFILES = IO::ArgFiles.new( @ARGS || $*IN );
> .say for lines;
> }
the way i understand https://docs.perl6.org/language/variables, my
dynamic (m
hello Vittore,
> Ok, I am 100% sure that, if people use it, eventually $*ARGFILES will
> become as fast as $*IN. Because of people like Liz working on the project
functions like slurp, lines, words already depends on $*ARGFILES (which
is awesome, i think) so i have no doubt there will be attentio
You can create your own $*ARGFILES.
sub MAIN ( +@ARGS ){
my $*ARGFILES = IO::ArgFiles.new( @ARGS || $*IN );
.say for lines;
}
Note that IO::ArgFiles is now only just a subclass of IO::CatHandle.
On Mon, Sep 23, 2019 at 2:51 PM Marc Chantreux wrote:
> hello,
>
> > > multi s
Thanks you too
> $*ARGFILES is the correct FH to use when it comes to write unix filters
> (as it was in the other examples of the page).
>
Ok, I am 100% sure that, if people use it, eventually $*ARGFILES will
become as fast as $*IN. Because of people like Liz working on the project
> nice ...
hello liz and Vittore,
> bypassing $*ARGFILES.lines by using $*IN.lines, makes it faster for me than
> using slurp
$*ARGFILES is the correct FH to use when it comes to write unix filters
(as it was in the other examples of the page).
> > say lines.map(*.Int).sum
i recently read that >> cou
hello,
> > multi sub MAIN ( :$c ) { say [+] lines>>.chars }
> Isn't that just `slurp.chars` ?
correct :)
> > multi sub MAIN ( :$w ) { say [+] lines.map: +*.words }
> Isn't that just `+words` ?
Aren't you awesome ? At least you're right: the doc says:
multi sub words
( IO::Handle:D $fh =
for optional options like -H, use "multi sub main" - then you can have
different sets of options available without having to fiddle with *@rest
-y
On Mon, Sep 23, 2019 at 2:20 PM Elizabeth Mattijsen wrote:
> > On 23 Sep 2019, at 19:53, Marc Chantreux wrote:
> > multi sub MAIN ( :$l ) { say +
Hi Liz,
bypassing $*ARGFILES.lines by using $*IN.lines, makes it faster for me than
using slurp, and seems like a more logic algorithm to solve the problem. I
think that, for any person that seriously thinks about using perl6 for
one-liners, using $*IN instead of $*ARGFILES is something to take int
> On 23 Sep 2019, at 19:53, Marc Chantreux wrote:
> multi sub MAIN ( :$l ) { say +lines }
> multi sub MAIN ( :$c ) { say [+] lines>>.chars }
Isn't that just `slurp.chars` ?
> multi sub MAIN ( :$w ) { say [+] lines.map: +*.words }
Isn't that just `+words` ?
> now i want grep that can have b
I've tested with a file with 1M numbers between 1..100.
The quick answer would be: use `say lines.sum`. But since `[+]` is already
internally optimized to `.sum`, that doesn't make much sense.
If you know that you will only see integer numbers, you can make it a bit
faster by explicitly coerci
say [+] $*IN.lines>>.Int
is quite faster.
On Mon, Sep 23, 2019 at 7:58 PM Marc Chantreux wrote:
> hello,
>
> question: in raku, is there a faster solution than
>
> say [+] lines
>
> long story;
>
> here is a thread i would like to reply to
>
>
> https://stackoverflow.com/questions/450799/shel
hello people,
short question: how to use $*ARGFILES in a MAIN function?
context:
as an exercice as well as demo, i reimplement unix filters
(cat, grep, wc, join, paste, ...). Basic wc could be
multi sub MAIN ( :$l ) { say +lines }
multi sub MAIN ( :$c ) { say [+] lines>>.chars }
multi sub
hello,
question: in raku, is there a faster solution than
say [+] lines
long story;
here is a thread i would like to reply to
https://stackoverflow.com/questions/450799/shell-command-to-sum-integers-one-per-line
because:
* the perl5 answer is fast compared to the other dynamic langages
* t
13 matches
Mail list logo