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