Re: Inconsistencies with "with" chained to "for"
Hi Vadim, Thank you! I opened issue #5049. On Sun, Aug 28, 2022 at 12:56 AM Vadim Belman wrote: > > Looks like it worth a bug report. I was probably stumbling upon this too > for a couple of times. > > Best regards, > Vadim Belman > > > On Aug 27, 2022, at 2:24 AM, Fernando Santagata < > nando.santag...@gmail.com> wrote: > > > > Hello, > > I noticed this behavior: > > > > [0] > my @a = > > [a b c d e] > > [1] > .say with $_ for @a > > () > > [2] > .say if .defined for @a > > a > > b > > c > > d > > e > > [3] > (.say with $_) for @a > > a > > b > > c > > d > > e > > [4] > (.say if .defined) for @a > > a > > b > > c > > d > > e > > > > Apparently in this case "with" works only as a statement modifier while > "if" works both ways. > > Is this a known behavior with well understood reasons, or should I open > an issue? > > > > -- > > Fernando Santagata > > -- Fernando Santagata
exe?
Hi All, Is there a way to convert a Windows Raku program to to an executable (.exe) file? Many thanks, -T -- ~~ Computers are like air conditioners. They malfunction when you open windows ~~
Re: rotor in comb?
hello everyone and thanks Bruce and William for help, On Sat, Aug 27, 2022 at 01:25:32PM -0700, William Michels wrote: > ~$ raku -e '++(my %digraphs){$_} for slurp.lc.match(:global, :exhaustive, > /<[a..z]>**2/); .say for %digraphs.sort(-*.value);' richard3.txt I don't see a huge difference with the code Bruce posted previously. Did I miss something? On Sat, Aug 27, 2022 at 12:24:50PM -0500, Bruce Gray wrote: >> I do *not* think you can ("move the cursor backward in the comb >> regex"); See https://docs.raku.org/routine/comb : ... "returns a Seq >> of non-overlapping matches" ... I was diging in the regex syntax part of the doc but indeed: the comb part is clear, its name is too and I realize I was abusing it: match is the good thing to do. >> The "non-overlapping" nature is the problem. >> (Please let me know if this turns out to be incorrect!) If the cursor can be manipulated from the regex itself (:exhaustive is the thing I failed to find) but I try to be idiomatic so your answer fits! I noticed the usage of the hyperoperator » and wanted to know if we could take advantage if parallelism I found it a bit faster. It also shows that slurp.split('\n') is faster than lines by far (see below). Thanks again for helping me! slurp : 15.89s user 0.37s system 105% cpu 15.373 total slurp, split, race : 15.10s user 0.11s system 104% cpu 14.502 total line, race : 24.96s user 0.19s system 314% cpu 7.991 total set vi.macros vi.macros vi.macros vi.macros vi.macros \ vi.macros vi.macros vi.macros vi.macros vi.macros \ vi.macros vi.macros vi.macros vi.macros vi.macros \ vi.macros vi.macros vi.macros vi.macros vi.macros \ vi.macros vi.macros vi.macros vi.macros vi.macros \ vi.macros vi.macros vi.macros vi.macros vi.macros \ vi.macros vi.macros vi.macros vi.macros vi.macros \ vi.macros vi.macros vi.macros vi.macros vi.macros time raku -e 'slurp.lc.match(:exhaustive, /(<[a..z]> ** 2)/)».Str.Bag .sort({ -.value, ~.key })' "$@" time raku -e 'slurp.split("\n").map({ |map ~*, .lc.match(:exhaustive, /(<[a..z]> ** 2)/) }).flat.Bag.sort({-.value, .key})' "$@" time raku -e 'lines.race.map({ |map ~*, .lc.match(:exhaustive, /(<[a..z]> ** 2)/) }).flat.Bag.sort({-.value, .key})' "$@" raku -e ' lines.race.map({ |map ~*, .lc.match(:exhaustive, /(<[a..z]> ** 2)/) }).flat.Bag.sort({-.value, .key}).map: &say ' -- Marc Chantreux Pôle de Calcul et Services Avancés à la Recherche (CESAR) http://annuaire.unistra.fr/p/20200
BEGIN {} question
Hi All, I am thinking of using BEGIN {} to fire up a splash screen (libnotify). Question: is what happens between the brackets isolated from the rest of the code? If I set variable values or declare variables, are they wiped out, etc.? Many thanks, -T -- If I had a dime every time I didn't know what was going on, I'd be like, "Why is everyone giving me all these dimes?"
Re: BEGIN {} question
> On Aug 28, 2022, at 5:58 PM, ToddAndMargo via perl6-users > wrote: > > Hi All, > > I am thinking of using > > BEGIN {} > > to fire up a splash screen (libnotify). > > Question: is what happens between the brackets > isolated from the rest of the code? If I set > variable values or declare variables, are they > wiped out, etc.? > > Many thanks, > -T BEGIN blocks create a lexical scope, because they are *blocks*, so any variables that you declare within the block don't exist outside the block. Variables that you define in the lexical scope *surrounding* the BEGIN block can have their values set inside the BEGIN block, and those values will be retained after BEGIN ends. my $a_var; sub do_something ( ) { say "did something! By the way: ", (:$a_var), ' inside a sub called from the BEGIN block, because the var is shared between them (same lexical scope).'; } BEGIN { $a_var = 42; my $b_var = 11; say "a_var is $a_var within the BEGIN block"; say "b_var is $b_var within the BEGIN block"; do_something(); } say "a_var is still $a_var outside the BEGIN block"; # say "b_var is still $b_var outside the BEGIN block"; # Commented out, because illegal! Output: a_var is 42 within the BEGIN block b_var is 11 within the BEGIN block did something! By the way: a_var => 42 inside a sub called from the BEGIN block, because the var is shared between them (same lexical scope). a_var is still 42 outside the BEGIN block -- Hope this helps, Bruce Gray (Util of PerlMonks)
Re: BEGIN {} question
On 8/28/22 19:11, Bruce Gray wrote: On Aug 28, 2022, at 5:58 PM, ToddAndMargo via perl6-users wrote: Hi All, I am thinking of using BEGIN {} to fire up a splash screen (libnotify). Question: is what happens between the brackets isolated from the rest of the code? If I set variable values or declare variables, are they wiped out, etc.? Many thanks, -T BEGIN blocks create a lexical scope, because they are *blocks*, so any variables that you declare within the block don't exist outside the block. Variables that you define in the lexical scope *surrounding* the BEGIN block can have their values set inside the BEGIN block, and those values will be retained after BEGIN ends. my $a_var; sub do_something ( ) { say "did something! By the way: ", (:$a_var), ' inside a sub called from the BEGIN block, because the var is shared between them (same lexical scope).'; } BEGIN { $a_var = 42; my $b_var = 11; say "a_var is $a_var within the BEGIN block"; say "b_var is $b_var within the BEGIN block"; do_something(); } say "a_var is still $a_var outside the BEGIN block"; # say "b_var is still $b_var outside the BEGIN block"; # Commented out, because illegal! Output: a_var is 42 within the BEGIN block b_var is 11 within the BEGIN block did something! By the way: a_var => 42 inside a sub called from the BEGIN block, because the var is shared between them (same lexical scope). a_var is still 42 outside the BEGIN block Hi Bruce, Thank you! I understand now. I was channeling my old Modula2 days, where everything had a BEGIN and an END. I did not realize BEGIN was a "name". A special name of a subroutine that would run before compile was complete. I am now thinking of firing off a call to libnotify with a delayed close out time to simulate a splash screen. Question, would BEGIN go at the top or the bottom of my code? Seems the compiler would hit it first at the top, but I do not know if it makes a full pass of everything before firing off the BEGIN. -T