Re: bash "."?
On 2020-05-14 23:57, Shlomi Fish wrote: (note that I comaintain it now). Then it will be awesome! Thank yuo!
Re: bash "."?
On 2020-05-14 23:57, Shlomi Fish wrote: The INI formats have no official (ISO/etc.) standard, and there are many variations of them. See, for example, the various options that https://metacpan.org/pod/Config::IniFiles accepts (note that I comaintain it now). I will be playing with them shortly. I really want to see how CONFIG handles section titles. Thank you! -T # zef install Config::IniFiles ===> Searching for: Config::IniFiles No candidates found matching identity: Config::IniFiles :'( :'( :'(
Re: bash "."?
Hi Todd! On Thu, 14 May 2020 14:40:49 -0700 ToddAndMargo via perl6-users wrote: > On 2020-05-14 08:22, Peter Pentchev wrote: > > On Thu, May 14, 2020 at 04:39:18AM -0700, ToddAndMargo via perl6-users > > wrote: > >> On 2020-05-13 22:27, Bruce Gray wrote: > >>> > >>> > On May 13, 2020, at 9:37 PM, ToddAndMargo via perl6-users > wrote: > > Hi All, > > Do we have anything like Bash's "." statement where > we can read in a bunch of values from a .cfg file? > (I think it is called "include", but I am not sure.) > > . /etc/sysconfig/network-scripts/ifcfg-br0 > > which populates these (and other) variables > > DEVICE=br0 > TYPE=Bridge > ONBOOT=yes > USERCTL=yes > DELAY=0 > NM_CONTROLLED=yes > BOOTPROTO=none > PREFIX=24 > ... > > Many thanks, > -T > >>> > >>> Hi Todd, > >>> > >>> FYI, the `.` Bash command is also called `source`, which is easier to > >>> search on the Web, and clearer in email: https://ss64.com/bash/source.html > >>> > >>> The closest equivalent in Raku is: > >>> https://docs.raku.org/routine/EVALFILE > >>> , which could be used for config data like so: > >>> $ cat a.dat > >>> $foo = "bar"; > >>> $baz = "quxx"; > >>> > >>> $ perl6 -e 'our ($foo, $baz); EVALFILE "a.dat"; .say for $foo, > >>> $baz;' bar > >>> quxx > >>> > >>> , but please do not use it for this purpose. > >>> > >>> EVALFILE is in all-caps to show that it might be dangerous and not for > >>> general use; it is “grep-able evil”, and could eval any valid Raku code, > >>> even evil things like `run “rm -rf /“`. > >>> > >>> IMHO, Bash's `source`-style of loading variables pollutes the main > >>> namespace and causes hard-to-debug “action at a distance”. In Raku (or > >>> any other dynamic language), the use of some kind of Config module is > >>> safer and cleaner: https://modules.raku.org/t/CONFIG > >>> https://github.com/raku-community-modules/perl6-Config-JSON > >>> https://github.com/Skarsnik/perl6-config-simple > >>> https://metacpan.org/pod/Config::Tiny > >>> > >>> For example: > >>> > >>> $ cat config.json > >>> { > >>> "baz": "quxx", > >>> "foo": "bar” > >>> } > >>> $ perl6 -e 'use Config::JSON; my %c; %c{$_} = jconf($_) for ; > >>> say %c{$_} for ;' bar > >>> quxx > >>> > >>> $ cat b.dat > >>> foo = bar > >>> baz = quxx > >>> $ perl6 -e 'use Config::Tiny:from; my $conf = > >>> Config::Tiny.read("b.dat"); .say for $conf<_>' bar > >>> quxx > >>> > >>> > >>> — > >>> Hope this helps, > >>> Bruce Gray (Util of PerlMonks) > >> > >> > >> Hi Bruce, > >> > >> I looked at the first two links above. Neither showed > >> the format of the data being read. But you did. Is > >> there some reason why the two links did not show the format? > > > > Well, they do both say they read .ini-style files. I think that they > > will both be able to read simple key=value files like the network > > definition sysconfig ones on RedHat-style systems that you seem to want. > > Keep in mind that the shell probably interprets a bit more, so some > > configuration-reading modules may e.g. return the quotes around the > > value or something like that; take them for a spin and see. > > Also, it's almost certain that these modules will not be able to help if > > the files that you read make use of the fact that the shell performs > > variable expansion: they will not be able to expand other variables in > > lines like: > > > > KEYFILE="/etc/keys/$HOSTNAME.key" > > > > or something like that. > > > > If you come across files like that, you may have to write your own > > parser. > > > > For some general information on ini-like files, see > > https://en.wikipedia.org/wiki/INI_file > > > > G'luck, > > Peter > > > > Hi Peter, > > That was extremely helpful! I never realized INI > files were standardized. > The INI formats have no official (ISO/etc.) standard, and there are many variations of them. See, for example, the various options that https://metacpan.org/pod/Config::IniFiles accepts (note that I comaintain it now). > I will be playing with them shortly. I really want > to see how CONFIG handles section titles. > > Thank you! > > -T -- Shlomi Fish https://www.shlomifish.org/ Funny Anti-Terrorism Story - https://shlom.in/enemy Summer Glau showed Kermit the Frog how easy it can be to be green. — https://www.shlomifish.org/humour/bits/facts/Summer-Glau/ Please reply to list if it's a mailing list post - https://shlom.in/reply .
Re: bash "."?
On 2020-05-15 00:26, ToddAndMargo via perl6-users wrote: On 2020-05-14 23:57, Shlomi Fish wrote: The INI formats have no official (ISO/etc.) standard, and there are many variations of them. See, for example, the various options that https://metacpan.org/pod/Config::IniFiles accepts (note that I comaintain it now). I will be playing with them shortly. I really want to see how CONFIG handles section titles. Thank you! -T # zef install Config::IniFiles ===> Searching for: Config::IniFiles No candidates found matching identity: Config::IniFiles :'( :'( :'( I downloaded it from git and the directions did not work # find /home/linuxutil/perl-Config-IniFiles-master -iname Build.PL # perl /home/linuxutil/say.p5/say-master/Build.PL Can't locate Module/Build/Pluggable.pm in @INC (you may need to install the Module::Build::Pluggable module) (@INC contains: /usr/local/lib64/perl5/5.30 /usr/local/share/perl5/5.30 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at /home/linuxutil/say.p5/say-master/Build.PL line 3. BEGIN failed--compilation aborted at /home/linuxutil/say.p5/say-master/Build.PL line 3.
Re: bash "."?
On Fri, May 15, 2020 at 01:24:27AM -0700, ToddAndMargo via perl6-users wrote: > On 2020-05-15 00:26, ToddAndMargo via perl6-users wrote: > > On 2020-05-14 23:57, Shlomi Fish wrote: > > > The INI formats have no official (ISO/etc.) standard, and there are many > > > variations of them. See, for example, the various options that > > > https://metacpan.org/pod/Config::IniFiles accepts (note that I > > > comaintain it > > > now). > > > > > > > I will be playing with them shortly. I really want > > > > to see how CONFIG handles section titles. > > > > > > > > Thank you! > > > > > > > > -T > > > > # zef install Config::IniFiles > > ===> Searching for: Config::IniFiles > > No candidates found matching identity: Config::IniFiles > > > > > > :'( :'( :'( > > > I downloaded it from git and the directions did not work Let's start with "you do realize that Config::IniFiles is a Perl 5 module, not a Raku one, right?"... of course, it might be possible to use it through Raku's Inline::Perl5, but it would be much, much easier to use one of the native Raku modules that people already mentioned in this thread. G'luck, Peter -- Peter Pentchev r...@ringlet.net r...@debian.org p...@storpool.com PGP key:http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13 signature.asc Description: PGP signature
Rakudo Star 2020.05-rc2
Good day Rakoons! After the initial -rc1, I've received some feedback and have made a couple small tweaks to fix a few issues. This has resulted in a -rc2, which has been made public for testing. https://dist.tyil.nl/raku/rakudo-star/rakudo-star-2020.05-rc2.tar.gz https://dist.tyil.nl/raku/rakudo-star/rakudo-star-2020.05-rc2.tar.gz.asc https://dist.tyil.nl/raku/rakudo-star/rakudo-star-2020.05-rc2.tar.gz.checksums.txt Once more, testing is much appreciated! -- With kind regards, Patrick Spek www: https://www.tyil.nl/ mail: p.s...@tyil.nl pgp: 1660 F6A2 DFA7 5347 322A 4DC0 7A6A C285 E2D9 8827 social: https://soc.fglt.nl/tyil git:https://home.tyil.nl/git signature.asc Description: PGP signature
Re: RFE: ini documentation
On Thu, May 14, 2020 at 06:51:44PM -0700, ToddAndMargo via perl6-compiler wrote: > Dear Config, > > https://modules.raku.org/dist/Config:cpan:TYIL > > Would you please consider add the following reference to your > web page: > > https://en.wikipedia.org/wiki/INI_file > > It gives a wonderful description of INI files. And > there are folks out there that do not realize that INI > files are standardized or how to write them > > Many thanks, > -T If there's a parser for ini that works with Config, I will link to that particular parser in the README of Config. Linking to random formats that aren't supported seems like a weird addition to the documentation. According to modules.raku.org[1], there's three implementations, which are included in the README already: - Config::Parser::toml - Config::Parser::yaml - Config::Parser::json I'm currently not planning to write Config::Parser::ini, but I'd gladly welcome any additional parsers, and will respond to any questions about implementing one to the best of my capabilities. [1]: https://modules.raku.org/search/?q=Config%3A%3AParser -- With kind regards, Patrick Spek www: https://www.tyil.nl/ mail: p.s...@tyil.nl pgp: 1660 F6A2 DFA7 5347 322A 4DC0 7A6A C285 E2D9 8827 social: https://soc.fglt.nl/tyil git:https://home.tyil.nl/git signature.asc Description: PGP signature
Re: bash "."?
Hi Todd! On Fri, 15 May 2020 00:26:28 -0700 ToddAndMargo via perl6-users wrote: > On 2020-05-14 23:57, Shlomi Fish wrote: > > The INI formats have no official (ISO/etc.) standard, and there are many > > variations of them. See, for example, the various options that > > https://metacpan.org/pod/Config::IniFiles accepts (note that I comaintain > > it now). > > > >> I will be playing with them shortly. I really want > >> to see how CONFIG handles section titles. > >> > >> Thank you! > >> > >> -T > > # zef install Config::IniFiles > ===> Searching for: Config::IniFiles > No candidates found matching identity: Config::IniFiles > Sorry for the confusion, but https://metacpan.org/pod/Config::IniFiles is a Perl 5 module. I have no plans of translating it to Raku, but it may be accessible using a Perl5 <-> bridge. I just linked to it to illustrate the point of how there are many variations on the theme of inifiles. > > :'( :'( :'( -- Shlomi Fish https://www.shlomifish.org/ Freecell Solver - https://fc-solve.shlomifish.org/ Writing a BitKeeper replacement is probably easier at this point than getting its license changed. — Matt Mackall (who ended up writing a BitKeeper replacement) Please reply to list if it's a mailing list post - https://shlom.in/reply .
Re: bash "."?
On 2020-05-15 01:43, Shlomi Fish wrote: Hi Todd! On Fri, 15 May 2020 00:26:28 -0700 ToddAndMargo via perl6-users wrote: On 2020-05-14 23:57, Shlomi Fish wrote: The INI formats have no official (ISO/etc.) standard, and there are many variations of them. See, for example, the various options that https://metacpan.org/pod/Config::IniFiles accepts (note that I comaintain it now). I will be playing with them shortly. I really want to see how CONFIG handles section titles. Thank you! -T # zef install Config::IniFiles ===> Searching for: Config::IniFiles No candidates found matching identity: Config::IniFiles Sorry for the confusion, but https://metacpan.org/pod/Config::IniFiles is a Perl 5 module. I have no plans of translating it to Raku, but it may be accessible using a Perl5 <-> bridge. I just linked to it to illustrate the point of how there are many variations on the theme of inifiles. Rats! I will patiently await the Perl 6 version.
Re: bash "."?
There will never be a Perl 6 version. > On 15 May 2020, at 19:33, ToddAndMargo via perl6-users > wrote: > > On 2020-05-15 01:43, Shlomi Fish wrote: >> Hi Todd! >> On Fri, 15 May 2020 00:26:28 -0700 >> ToddAndMargo via perl6-users wrote: >>> On 2020-05-14 23:57, Shlomi Fish wrote: The INI formats have no official (ISO/etc.) standard, and there are many variations of them. See, for example, the various options that https://metacpan.org/pod/Config::IniFiles accepts (note that I comaintain it now). > I will be playing with them shortly. I really want > to see how CONFIG handles section titles. > > Thank you! > > -T >>> >>> # zef install Config::IniFiles >>> ===> Searching for: Config::IniFiles >>> No candidates found matching identity: Config::IniFiles >>> >> Sorry for the confusion, but https://metacpan.org/pod/Config::IniFiles is a >> Perl 5 module. I have no plans of translating it to Raku, but it may be >> accessible using a Perl5 <-> bridge. I just linked to it to illustrate the >> point of how there are many variations on the theme of inifiles. > > Rats! I will patiently await the Perl 6 version.
Re: bash "."?
On 2020-05-15 01:49, Peter Pentchev wrote: On Fri, May 15, 2020 at 01:24:27AM -0700, ToddAndMargo via perl6-users wrote: On 2020-05-15 00:26, ToddAndMargo via perl6-users wrote: On 2020-05-14 23:57, Shlomi Fish wrote: The INI formats have no official (ISO/etc.) standard, and there are many variations of them. See, for example, the various options that https://metacpan.org/pod/Config::IniFiles accepts (note that I comaintain it now). I will be playing with them shortly. I really want to see how CONFIG handles section titles. Thank you! -T # zef install Config::IniFiles ===> Searching for: Config::IniFiles No candidates found matching identity: Config::IniFiles :'( :'( :'( I downloaded it from git and the directions did not work Let's start with "you do realize that Config::IniFiles is a Perl 5 module, not a Raku one, right?"... of course, it might be possible to use it through Raku's Inline::Perl5, but it would be much, much easier to use one of the native Raku modules that people already mentioned in this thread. G'luck, Peter Ahh poop! I never thought someone would give me a module from another language to use. :'( -- ~~ Computers are like air conditioners. They malfunction when you open windows ~~
Re: bash "."?
On 2020-05-15 10:37, Elizabeth Mattijsen wrote: There will never be a Perl 6 version. what would you use in place of it?
Re: bash "."?
There might be a Raku version > On 15 May 2020, at 20:08, ToddAndMargo via perl6-users > wrote: > > On 2020-05-15 10:37, Elizabeth Mattijsen wrote: >> There will never be a Perl 6 version. > > > what would you use in place of it?
Re: bash "."?
On 15 May 2020, at 20:08, ToddAndMargo via perl6-users wrote: On 2020-05-15 10:37, Elizabeth Mattijsen wrote: There will never be a Perl 6 version. what would you use in place of it? On 2020-05-15 11:28, Elizabeth Mattijsen wrote: > There might be a Raku version > If Shlomi has anything to do with it, there will be :-) -- ~~~ Serious error. All shortcuts have disappeared. Screen. Mind. Both are blank. ~~~
Re: sqrt and Buf question
> On May 14, 2020, at 4:36 PM, ToddAndMargo via perl6-users > wrote: > > On 2020-05-14 08:13, Bruce Gray wrote: >>> On May 14, 2020, at 7:27 AM, ToddAndMargo via perl6-users >>> wrote: >>> >>> Hi All, >>> >>> 1) how do I get 40 or more digits out of sqrt? >> —snip— >> Use an Integer Root algorithm on ($number-you-want-the-root-of * 100 ** >> $number-of-digits-you-want), then shift the decimal point of the result. >> Exact code here: >> https://rosettacode.org/wiki/Integer_roots#Raku >> — >> Hope this helps, >> Bruce Gray (“Util” on RosettaCode, too) > > > sub integer_root ( Int $p where * >= 2, Int $n --> Int ) { >my Int $d = $p - 1; >my $guess = 10**($n.chars div $p); >my $iterator = { ( $d * $^x + $n div ($^x ** $d) ) div $p }; >my $endpoint = { $^x ** $p <= $n > and ($^x + 1) ** $p > $n }; >min (+$guess, $iterator ... $endpoint)[*-1, *-2]; > } > > say integer_root( 2, 2 * 100 ** 2000 ); > > > > It does help! I can reproduce noise to my heart's content! H. See my `srand` note at the end. > > Questions: > > what is $p in the sub declaration? Is it always a 2? $p is the “degree” of the root wanted; 2 for square root, 3 for cube root, etc. > > what is `$n` in the sub declaration? $n is the number that you want the root of. > Looks like > the third set of numbers is the digits I want. > > what is the second number (100)? 100 is (10 ** $degree), and the degree is `2` for square root. > > And what is `2 * 100 ** 2000 `? Is that `(2 x 100)^ 2000` > ((2 times 100) to the 2000 power? As Peter Pentchev pointed out, A * B ** C is always interpreted as A * (B ** C). > > > say integer_root( 2, 2 * 100 ** 4 ); > 14142 > > > say 3.sqrt > 1.7320508075688772 > > > say integer_root( 2, 3 * 100 ** 16 ); > 17320508075688772 > > > -T I see from your question that while the RosettaCode solution is generally clear for the task itself, the use of `100` in the calling code is less clear. (I will fix that on RC) An "integer root" algorithm, taken by itself, only gives you a fast/direct method to find `($number ** (1/$root_wanted)).floor` without ever using floating point. To use such an algorithm to produce more digits, we have to *scale* the number such that the root of the scaling factor is a power of 10, so the scaling factor must be a power of (10 ** $root_wanted). For square roots, we need (10 ** 2), which is why the RC code says `100`; the square root of 100 is 10, and `10` slides the decimal point while preserving the digits. $ perl6 -e 'say .sqrt.floor for 2, 200, 2, 200, 2' 1 14 141 1414 14142 So, the "root wanted" (like 2 for square root, 3 for cube root, etc) occurs twice in the integer_root() call; once as the first argument `p`, and again in the exponent of 10 in the multiplier for the second argument. e.g. to get the first 42 digits of the cube root of 88: say integer_root( 3, 88 * ((10 ** 3) ** 42) ); 4447960181138631042330726753444314393037398 Or: sub lots_of_digits_of_root ( $radicand, $degree, $extra_digit_count ) { return integer_root( $degree, $radicand * ((10 ** $degree) ** $extra_digit_count) ); } say lots_of_digits_of_root( 88, 3, 42 ); 4447960181138631042330726753444314393037398 Finally, you said "reproduce noise", which makes me think that you might be going down this sqrt(2)-road from having tried Raku's rand() for noise, but hitting the problem of its non-reproducibility. If so, a much simpler method would be to use the built-in solution: Call `srand` to force `rand` to use a some fixed starting-point. # All different: $ perl6 -e ' say (^10).roll(*).head(15);' # (5 5 7 9 8 7 6 9 1 2 1 3 3 0 6) $ perl6 -e ' say (^10).roll(*).head(15);' # (2 7 3 4 3 9 9 3 2 2 4 6 5 9 9) $ perl6 -e ' say (^10).roll(*).head(15);' # (2 2 1 7 1 7 6 3 1 2 4 1 3 1 4) $ perl6 -e ' say (^10).roll(*).head(15);' # (4 7 1 0 8 5 6 6 0 1 8 2 3 3 6) # All identical $ perl6 -e 'srand(42); say (^10).roll(*).head(15);' # (4 3 9 3 6 1 1 0 0 5 8 3 6 7 0) $ perl6 -e 'srand(42); say (^10).roll(*).head(15);' # (4 3 9 3 6 1 1 0 0 5 8 3 6 7 0) $ perl6 -e 'srand(42); say (^10).roll(*).head(15);' # (4 3 9 3 6 1 1 0 0 5 8 3 6 7 0) $ perl6 -e 'srand(42); say (^10).roll(*).head(15);' # (4 3 9 3 6 1 1 0 0 5 8 3 6 7 0) — HTH, Util Harry knew pi to 3.141592 because accuracy to one part in a million was enough for most practical purposes. Hermione knew one hundred digits of pi because that was how many digits had been printed in the back of her maths textbook. https://www.hpmor.com/chapter/9
Re: sqrt and Buf question
On 2020-05-15 12:09, Bruce Gray wrote: On May 14, 2020, at 4:36 PM, ToddAndMargo via perl6-users wrote: On 2020-05-14 08:13, Bruce Gray wrote: On May 14, 2020, at 7:27 AM, ToddAndMargo via perl6-users wrote: Hi All, 1) how do I get 40 or more digits out of sqrt? —snip— Use an Integer Root algorithm on ($number-you-want-the-root-of * 100 ** $number-of-digits-you-want), then shift the decimal point of the result. Exact code here: https://rosettacode.org/wiki/Integer_roots#Raku — Hope this helps, Bruce Gray (“Util” on RosettaCode, too) sub integer_root ( Int $p where * >= 2, Int $n --> Int ) { my Int $d = $p - 1; my $guess = 10**($n.chars div $p); my $iterator = { ( $d * $^x + $n div ($^x ** $d) ) div $p }; my $endpoint = { $^x ** $p <= $n and ($^x + 1) ** $p > $n }; min (+$guess, $iterator ... $endpoint)[*-1, *-2]; } say integer_root( 2, 2 * 100 ** 2000 ); It does help! I can reproduce noise to my heart's content! H. See my `srand` note at the end. Questions: what is $p in the sub declaration? Is it always a 2? $p is the “degree” of the root wanted; 2 for square root, 3 for cube root, etc. what is `$n` in the sub declaration? $n is the number that you want the root of. Looks like the third set of numbers is the digits I want. what is the second number (100)? 100 is (10 ** $degree), and the degree is `2` for square root. And what is `2 * 100 ** 2000 `? Is that `(2 x 100)^ 2000` ((2 times 100) to the 2000 power? As Peter Pentchev pointed out, A * B ** C is always interpreted as A * (B ** C). say integer_root( 2, 2 * 100 ** 4 ); 14142 say 3.sqrt 1.7320508075688772 say integer_root( 2, 3 * 100 ** 16 ); 17320508075688772 -T I see from your question that while the RosettaCode solution is generally clear for the task itself, the use of `100` in the calling code is less clear. (I will fix that on RC) An "integer root" algorithm, taken by itself, only gives you a fast/direct method to find `($number ** (1/$root_wanted)).floor` without ever using floating point. To use such an algorithm to produce more digits, we have to *scale* the number such that the root of the scaling factor is a power of 10, so the scaling factor must be a power of (10 ** $root_wanted). For square roots, we need (10 ** 2), which is why the RC code says `100`; the square root of 100 is 10, and `10` slides the decimal point while preserving the digits. $ perl6 -e 'say .sqrt.floor for 2, 200, 2, 200, 2' 1 14 141 1414 14142 So, the "root wanted" (like 2 for square root, 3 for cube root, etc) occurs twice in the integer_root() call; once as the first argument `p`, and again in the exponent of 10 in the multiplier for the second argument. e.g. to get the first 42 digits of the cube root of 88: say integer_root( 3, 88 * ((10 ** 3) ** 42) ); 4447960181138631042330726753444314393037398 Or: sub lots_of_digits_of_root ( $radicand, $degree, $extra_digit_count ) { return integer_root( $degree, $radicand * ((10 ** $degree) ** $extra_digit_count) ); } say lots_of_digits_of_root( 88, 3, 42 ); 4447960181138631042330726753444314393037398 Finally, you said "reproduce noise", which makes me think that you might be going down this sqrt(2)-road from having tried Raku's rand() for noise, but hitting the problem of its non-reproducibility. If so, a much simpler method would be to use the built-in solution: Call `srand` to force `rand` to use a some fixed starting-point. # All different: $ perl6 -e ' say (^10).roll(*).head(15);' # (5 5 7 9 8 7 6 9 1 2 1 3 3 0 6) $ perl6 -e ' say (^10).roll(*).head(15);' # (2 7 3 4 3 9 9 3 2 2 4 6 5 9 9) $ perl6 -e ' say (^10).roll(*).head(15);' # (2 2 1 7 1 7 6 3 1 2 4 1 3 1 4) $ perl6 -e ' say (^10).roll(*).head(15);' # (4 7 1 0 8 5 6 6 0 1 8 2 3 3 6) # All identical $ perl6 -e 'srand(42); say (^10).roll(*).head(15);' # (4 3 9 3 6 1 1 0 0 5 8 3 6 7 0) $ perl6 -e 'srand(42); say (^10).roll(*).head(15);' # (4 3 9 3 6 1 1 0 0 5 8 3 6 7 0) $ perl6 -e 'srand(42); say (^10).roll(*).head(15);' # (4 3 9 3 6 1 1 0 0 5 8 3 6 7 0) $ perl6 -e 'srand(42); say (^10).roll(*).head(15);' # (4 3 9 3 6 1 1 0 0 5 8 3 6 7 0) — HTH, Util Harry knew pi to 3.141592 because accuracy to one part in a million was enough for most practical purposes. Hermione knew one hundred digits of pi because that was how many digits had been printed in the back of her maths textbook. https://www.hpmor.com/chapter/9 Thank you!!!
Re: fill in form
On 2020-05-13 14:05, Peter Pentchev wrote: So... I believe Timo gave you that as an example how to use a grid to position the various controls (buttons, text labels, input fields). You start there, you figure out what text labels, what input fields, what buttons you need, and then you use the 03-grid.p6 example as a base on how to do this with Raku and GTK+. Actually, he showed me the end result, not how he did it. I really need to know how he did it
Re: fill in form
On Fri, May 15, 2020 at 02:51:10PM -0700, ToddAndMargo via perl6-users wrote: > On 2020-05-13 14:05, Peter Pentchev wrote: > > So... I believe Timo gave you that as an example how to use a grid to > > position the various controls (buttons, text labels, input fields). > > You start there, you figure out what text labels, what input fields, > > what buttons you need, and then you use the 03-grid.p6 example as a base > > on how to do this with Raku and GTK+. > > Actually, he showed me the end result, not how he did it. > I really need to know how he did it Um, what he showed you was not in any way related to GTK+; it was an example of using grid layout in Cascading Style Sheets (CSS), a widely-used extension to HTML for making webpages. His point was to illustrate the *idea* of aligning buttons, text labels, and text input boxes to a grid. So you posted a screenshot of running the 03-grid.p6 example. It showed a couple of buttons and a text label, and it aligned them in the way described in the source code. Play around with it a bit, move the buttons and the text labels around, create another element or two, look at the other examples, maybe the one that says "Hello World", maybe the one that is called "text", see what other types of GTK+ things you can put onto the grid. G'luck, Peter -- Peter Pentchev r...@ringlet.net r...@debian.org p...@storpool.com PGP key:http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13 signature.asc Description: PGP signature
Re: fill in form
On 2020-05-15 15:23, Peter Pentchev wrote: On Fri, May 15, 2020 at 02:51:10PM -0700, ToddAndMargo via perl6-users wrote: On 2020-05-13 14:05, Peter Pentchev wrote: So... I believe Timo gave you that as an example how to use a grid to position the various controls (buttons, text labels, input fields). You start there, you figure out what text labels, what input fields, what buttons you need, and then you use the 03-grid.p6 example as a base on how to do this with Raku and GTK+. Actually, he showed me the end result, not how he did it. I really need to know how he did it Um, what he showed you was not in any way related to GTK+; it was an example of using grid layout in Cascading Style Sheets (CSS), a widely-used extension to HTML for making webpages. His point was to illustrate the *idea* of aligning buttons, text labels, and text input boxes to a grid. So you posted a screenshot of running the 03-grid.p6 example. It showed a couple of buttons and a text label, and it aligned them in the way described in the source code. Play around with it a bit, move the buttons and the text labels around, create another element or two, look at the other examples, maybe the one that says "Hello World", maybe the one that is called "text", see what other types of GTK+ things you can put onto the grid. G'luck, Peter With the exception that I do not know how to get the data back out of the pop up. The example does not even have a `okay` and `cancel` button
Re: bash "."?
On Fri, May 15, 2020 at 13:47 ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > > >> On 15 May 2020, at 20:08, ToddAndMargo via perl6-users < > perl6-us...@perl.org> wrote: > >> > >> On 2020-05-15 10:37, Elizabeth Mattijsen wrote: > >>> There will never be a Perl 6 version. > >> > >> > >> what would you use in place of it? Todd, I haven't kept up with the details of what you really need, but I really like the Raku module Config::TOML for my needs. It might not work if you have to adhere to some other standard, but if you have control it's pretty slick. -Tom
Re: bash "."?
On 2020-05-15 17:26, Tom Browder wrote: On Fri, May 15, 2020 at 13:47 ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: >> On 15 May 2020, at 20:08, ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: >> >> On 2020-05-15 10:37, Elizabeth Mattijsen wrote: >>> There will never be a Perl 6 version. >> >> >> what would you use in place of it? Todd, I haven't kept up with the details of what you really need, but I really like the Raku module Config::TOML for my needs. It might not work if you have to adhere to some other standard, but if you have control it's pretty slick. -Tom Hi Tom, https://github.com/atweiden/config-toml I read over it and got confused. No mention of how to handle section headers. Well that I could find. I am trying to read something like this: ; Raku: Conf::Infiles test INI : edit at your own risk [Backup paramters] target=B:\myDocsBackp\backup1 partition=BACKUP [eMail] smtp=smtp.bozo.com address=b...@theclown.com port=587 -T
Matching subpatterns in any order, conjunctions, negated matches
Regex engines by their nature care a lot about order, but I occasionally want to relax that to match for multiple multicharacter subpatterns where the order of them doesn't matter. Frequently the simplest thing to do is just to just do multiple matches. Let's say you're looking for words that have a "qu" a "th" and also, say an "ea". This works: my $DICT = "/usr/share/dict/american-english"; my @hits = $DICT.IO.open( :r ).lines.grep({/qu/}).grep({/th/}).grep({/ea/}); say @hits; # [bequeath bequeathed bequeathing bequeaths earthquake earthquake's earthquakes] It could be useful to be able to do it as one match though, for example, you might be using someone else's routine which takes a single regex as argument. I've been known to write things like this: my regex qu_th_ea { [ qu .*? th .*? ea ] | [ qu .*? ea .*? th ] | [ th .*? qu .*? ea ] | [ th .*? ea .*? qu ] | [ ea .*? th .*? qu ] | [ ea .*? qu .*? th ] }; my @hits = $DICT.IO.open( :r ).lines.grep({//}); That works, but it gets unwieldy quickly if you need to scale up the number of subpatterns. Recently though, I noticed the "conjunctions" feature, and it occured to me that this could be a very neat way of handling these things: my regex qu_th_ea { ^ [ .* qu .* & .* th .* & .* ea .* ] $ }; That's certainly much better, though unfortunately each element of the conjunction needs to match a substring of the same length, so pretty frequently you're stuck with the visual noise of bracketing subpatterns with pairs of .* Where things get interesting is when you want a negated match of one of the subpatterns. One of the things I like about the first approach using multiple chained greps is that it's easy to do a reverse match. What if you want words with "qu" and "th" but want to *skip* ones with an "ea"? my @hits = $DICT.IO.open( :r ).lines.grep({/qu/}).grep({/th/}).grep({!/ea/}); # [Asquith discotheque discotheque's discotheques quoth] To do that in one regex, it would be nice if there were some sort of adverb to do a reverse match, like say :not, then it would be straight-forward (NOTE: NON-WORKING CODE): my regex qu_th_ea { ^ [ .* qu .* & .* th .* & [ :not .* ea .* ] ] $ }; But since there isn't an adverb like this, what else might we do? The best idea I can come up with is this: my regex qu_th_ea { ^ [ .* qu .* & .* th .* & [ . ]* ] $ }; Where the third element of the conjunction should match only if none of the characters follow "ea". There's an oddity here though in that I think this can get confused by things like an "ea" that *precedes* the conjunction. So, the question then is: is there a neater way to embed a subpattern in a regex that does a negated match?
I need help with IO.e
Hi All,. Windows 7, sp1, x64 >raku -v This is Rakudo version 2020.01 built on MoarVM version 2020.01.1 implementing Perl 6.d. I am trying to get perl to tell me if a drive letter exists This is from Git's df command: >df -kPT H:\ Filesystem Type 1024-blocks Used Available Capacity Mounted on H: ntfs 38908 9964 28944 26% /h So, H:\ is there >raku "say H:\.IO.e" Could not open say H:\.IO.e. Failed to stat file: no such file or directory And in case I need \\ >raku "say H:\\.IO.e" Could not open say H:\\.IO.e. Failed to stat file: no such file or directory And in case I need a forward slashL: >raku "say H:/.IO.e" Could not open say H:/.IO.e. Failed to stat file: no such file or directory What am I doing wrong, this time? -T -- ~~ Computers are like air conditioners. They malfunction when you open windows ~~