Re: match's replacement name?

2014-05-22 Thread perl6-users
[ Sorry for not replying to the whole list earlier, I hope all readers
will be able to cope with fishing my reply out of the full-quotes. ]

Peter,

Here's what I came up with using the assignment variant of the
substitution operator:

> perl6-m -e 'my $text = "Well, hello!"; $text ~~ s[ +(\W) ] = my
$res = "Rhino$0"; say (:$res); say (:$text)'
> "res" => "Rhino,"
> "text" => "Rhino, hello!"

Hope to help!
  - Timo

On 05/23/2014 03:46 AM, Peter Schwenn wrote:
> Timo,
>
> Thank you, that works very nicely.  But I'm committed to   s///;  
> instead of .subst
>
> Best I've been able to do is such as:
>
>  $text ~~ s:g/ using \s+ RMA.Rhino (\W) /{$res="using Rhino$0"}$res/;
>  say $res;
>
> which works but makes the s///; quite a bit less readable.
>
> Thank you,
>
> Peter Schwenn
>
> p.s. by the way
>  $res = ($text ~~ s:g/ using \s+ RMA.Rhino (\W) /using Rhino$0/;)
> simply sets $res to True or False as you probably knew
>
>
> On Thu, May 22, 2014 at 8:29 PM, Timo Paulssen  <mailto:t...@wakelift.de>> wrote:
>
>
> On 05/23/2014 01:57 AM, Peter Schwenn wrote:
> > Dear Perl6-users,
> >
> > I'd like to print out the string value of the "replacement" after a
> > match from a statement like:
> >   s/pattern/replacement/; or its .subst version.
> >
> > (I'm able to print out the /pattern/ (match) string simply by
> printing
> > $/ ).
> >
> > Does the /replacement/ have a name so I can print it out too.
> >
> > Thank you,
>
> Hello Peter,
>
> > perl6-m -e 'my $text = "hello world"; my $res =
> $text.subst(/+
> \s+ <( + )>/, "heya!"); say $res.perl;'
> > "hello heya!"
>
> Is this at all what you're looking for?
>
> Cheers,
>   - Timo
>
>



signature.asc
Description: OpenPGP digital signature


Re: match's replacement name?

2014-05-24 Thread perl6-users

On 05/23/2014 09:08 PM, Peter Schwenn wrote:
> Timo, perl6-users,
>
> I don't want to print out the WHOLE text resulting from the match (in
> my case a long file,) but just the /replacement/ string.
>
> [...]
>
> Peter Schwenn
>
> On Thu, May 22, 2014 at 9:58 PM,  <mailto:perl6-users@perl.org>> wrote:
>
> [...]
>> perl6-m -e 'my $text = "Well, hello!"; $text ~~ s[ +(\W) ] =
>> my $res = "Rhino$0"; say (:$res); say (:$text)'
>>"res" => "Rhino,"
>> "text" => "Rhino, hello!"
>>
>> Hope to help! - Timo

Peter,

I think you may have missed the trick I put into that piece of code
where I assign to my $res first and chain-assign that into the s[ ... ]
operation. This way, you get only the part that has been replaced (in
the $res variable in this case).

Hope to help
  - Timo


signature.asc
Description: OpenPGP digital signature


Re: How do I handle Getopt::Long stray entries?

2020-05-11 Thread ToddAndMargo via perl6-users

On 2020-05-11 11:48, Peter Pentchev wrote:

On Mon, May 11, 2020 at 12:40:05AM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-10 23:47, Peter Pentchev wrote:

On Sun, May 10, 2020 at 06:20:02PM -0700, ToddAndMargo via perl6-users wrote:

Hi All,

https://modules.raku.org/dist/Getopt::Long:cpan:LEONT

How do I handle stray entries (unknown options) without
crashing?  Is there some grab bag I can stick all
those into?


When something signals an error using "die", you can catch it
using a CATCH block, especially if you know that the exception
thrown will be of a particular type. Now, the Getopt::Long
documentation does not explicitly mention it, but the module does
indeed define its own exception type, so you can do something
like this:

  use v6.d;
  use Getopt::Long;
  get-options('length=i' => my $length);
  CATCH { when Getopt::Long::Exception { .message.note; exit 1 } };
  if defined $length {
  say "Whee, length is $length";
  } else {
  say 'No length specified';
  }

The "when" condition within the CATCH block will make it only handle
these exceptions; any other errors will be handled (or passed through) in
their own way.

For more information about exceptions, see the documentation at
https://docs.raku.org/language/exceptions

G'luck,
Peter



I was actually hope to pick up the extra entries and use them

programname.pl6 --abc def ghi

I wanted to pick up ghi and use it


If "ghi" is not an option or an argument to an option, then I believe
that Getopt::Long, like similar modules in other languages, will
just leave it in @ARGV.


I also wanted to pick up an extra pair not on the list
(unknown option) and complain about them to the user


Well, it seems that Getopt::Long's exceptions are not quite that
detailed for the moment. It could be done though, the module could
be touched up a little bit so that there are different exceptions
for different problems encountered, and some of them contained
additional details... but that's up to the author or to whoever
decides to fork and extend the module :)

G'luck,
Peter



Thank you for the words of wisdom!

I am after the functionality I see in Fedora.  For
example

dnf [options]  [...]
$ dnf --enablerepo=* install firefox

But I will have to compromise

:-)

-T


Re: fill in form

2020-05-11 Thread ToddAndMargo via perl6-users

On 2020-05-11 15:47, ToddAndMargo via perl6-users wrote:

Hi All,

I want to create a fill in form in Windows: city,
state, etc., you fill in the data.

Is there some library out there for that?

Any words of wisdom?

Many thanks,
-T



GTK::Simple does work in Window, but I am at a loss
for an example of a fill in form.


Re: fill in form

2020-05-12 Thread ToddAndMargo via perl6-users

On 2020-05-11 17:14, ToddAndMargo via perl6-users wrote:

On 2020-05-11 15:47, ToddAndMargo via perl6-users wrote:

Hi All,

I want to create a fill in form in Windows: city,
state, etc., you fill in the data.

Is there some library out there for that?

Any words of wisdom?

Many thanks,
-T



GTK::Simple does work in Window, but I am at a loss
for an example of a fill in form.


Found this:

https://glade.gnome.org/

I have some reading to do!

Says it works with Perl too.  Five I presume.

-T


Re: fill in form

2020-05-12 Thread ToddAndMargo via perl6-users

> On 12/05/2020 00:47, ToddAndMargo via perl6-users wrote:
>> Hi All,
>>
>> I want to create a fill in form in Windows: city,
>> state, etc., you fill in the data.
>>
>> Is there some library out there for that?
>>
>> Any words of wisdom?
>>
>> Many thanks,
>> -T


On 2020-05-12 08:18, Timo Paulssen wrote:

Hi Todd,

normally I'd expect you want to create a grid with labels on the left
and text inputs on the right.

the examples/ folder in the GTK::Simple distribution (or the source on
github) has an example of the Grid class, which is very powerful.

The grid is possibly more complicated than you need it to be; instead
you can probably have one VBox that contains one HBox for every label +
input field.

One benefit that the Grid will give you is that you can much more easily
line up all the fill-in text inputs, whereas with a VBox of HBoxes it
may just make every text input as wide as possible so it (almost)
touches the end of the label, so different words ("city" vs "first
name") could result in different-sized text inputs.

hope that helps
   - Timo




Hi Timo,

You mean this one?

https://github.com/raku-community-modules/gtk-simple/blob/master/examples/03-grid.pl6

https://ibb.co/hgKHgW4

I do not see the utility of what I am after.

:'(

-T


Re: fill in form

2020-05-13 Thread ToddAndMargo via perl6-users

On 2020-05-13 14:05, Peter Pentchev wrote:

On Wed, May 13, 2020 at 07:58:08AM -0700, Todd Chester via perl6-users wrote:

On 12/05/2020 20:44, ToddAndMargo via perl6-users wrote:

On 12/05/2020 00:47, ToddAndMargo via perl6-users wrote:

Hi All,

I want to create a fill in form in Windows: city,
state, etc., you fill in the data.

Is there some library out there for that?

Any words of wisdom?

Many thanks,
-T



On 2020-05-12 08:18, Timo Paulssen wrote:

Hi Todd,

normally I'd expect you want to create a grid with labels on the left
and text inputs on the right.

the examples/ folder in the GTK::Simple distribution (or the source on
github) has an example of the Grid class, which is very powerful.

The grid is possibly more complicated than you need it to be; instead
you can probably have one VBox that contains one HBox for every label +
input field.

One benefit that the Grid will give you is that you can much more easily
line up all the fill-in text inputs, whereas with a VBox of HBoxes it
may just make every text input as wide as possible so it (almost)
touches the end of the label, so different words ("city" vs "first
name") could result in different-sized text inputs.

hope that helps
 - Timo




Hi Timo,

You mean this one?

https://github.com/raku-community-modules/gtk-simple/blob/master/examples/03-grid.pl6


https://ibb.co/hgKHgW4

I do not see the utility of what I am after.

:'(

-T


On 2020-05-13 05:26, Timo Paulssen wrote:

Is this not anything like what you're after?

https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.w3.org%2FTR%2F2016%2FCR-css-grid-1-20160929%2Fimages%2Fauto-placed-form.png&f=1&nofb=1

Kind Regards
    - Timo



Yes!


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+.

G'luck,
Peter



You would not happen to have a guide for the complete idiot?

Maybe an example too?

03-grid.p6 does not show how to extract the information.

Can I do all this with glade?
https://glade.gnome.org/

It has a nice tutorial.


Re: fill in form

2020-05-13 Thread ToddAndMargo via perl6-users

On 2020-05-13 15:29, ToddAndMargo via perl6-users wrote:

03-grid.p6 does not show how to extract the information.


But he does make this comment:

 Once again we're free to directly define and
 assign a variable to hold the widget for later on.

Which totally blows my mind.


bash "."?

2020-05-13 Thread ToddAndMargo via perl6-users

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


Re: bash "."?

2020-05-13 Thread ToddAndMargo via perl6-users

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)


Excellent!  Thank you!


Re: bash "."?

2020-05-14 Thread ToddAndMargo via perl6-users

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?

-T


sqrt and Buf question

2020-05-14 Thread ToddAndMargo via perl6-users

Hi All,

1) how do I get 40 or more digits out of sqrt?

2) how to I assist those bytes to a 40 (or more)
byte long Buf?

This obviously does not work:

my Num $x = 3.sqrt; my Buf $y = Buf.new($x)

Type check failed in initializing element #0 to Buf; expected uint8 but 
got Num (1.7320508075688772e0)

  in block  at  line 1

Many thanks,
-T


Re: sqrt and Buf question

2020-05-14 Thread ToddAndMargo via perl6-users

On 2020-05-14 05:51, Tobias Boege wrote:

On Thu, 14 May 2020, ToddAndMargo via perl6-users wrote:

Hi All,

1) how do I get 40 or more digits out of sqrt?



Meaningful digits? 


In this instance, I do not care about meaningful.  I only
care about the noise.  Just has to be repeatable.

I may have to look it up on a chart.


Not possible as sqrt uses limited precision. I think
the IEEE 754 doubles that I would suspect to be used internally are capped
way below 40 significant decimal digits.


2) how to I assist those bytes to a 40 (or more)
byte long Buf?

This obviously does not work:

my Num $x = 3.sqrt; my Buf $y = Buf.new($x)

Type check failed in initializing element #0 to Buf; expected uint8 but got
Num (1.7320508075688772e0)
   in block  at  line 1



You can convert the Num to a string and put that string into a Buf:

   Buf.new(3.sqrt.Str.encode)

That's what I'd do without any clue 


I am not disclosing on purpose.  Sorry for keeping you
in the dark.


at all about who is supposed to use
this Buf. At least the buffer is about as long as the number is decimal
digits, which seems to be what you wanted?

Regards,
Tobias



my Buf $x = Buf.new(3.sqrt.Str.encode)
Buf:0x<31 2E 37 33 32 30 35 30 38 30 37 35 36 38 38 37 37 32>


Thank you!


Re: sqrt and Buf question

2020-05-14 Thread ToddAndMargo via perl6-users

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!

Questions:

what is $p in the sub declaration? Is it always a 2?

what is `$n` in the sub declaration?  Looks like
the third set of numbers is the digits I want.

what is the second number (100)?

And what is `2 * 100 ** 2000 `?  Is that `(2 x 100)^ 2000`
((2 times 100) to the 2000 power?

> say integer_root( 2, 2 * 100 ** 4 );
14142

> say 3.sqrt
1.7320508075688772

> say integer_root( 2, 3 * 100 ** 16 );
17320508075688772


-T


Re: bash "."?

2020-05-14 Thread ToddAndMargo via perl6-users

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.

I will be playing with them shortly.  I really want
to see how CONFIG handles section titles.

Thank you!

-T


Re: sqrt and Buf question

2020-05-14 Thread ToddAndMargo via perl6-users

On 2020-05-14 05:51, Tobias Boege wrote:

On Thu, 14 May 2020, ToddAndMargo via perl6-users wrote:

Hi All,

1) how do I get 40 or more digits out of sqrt?



Meaningful digits? Not possible as sqrt uses limited precision. I think
the IEEE 754 doubles that I would suspect to be used internally are capped
way below 40 significant decimal digits.


2) how to I assist those bytes to a 40 (or more)
byte long Buf?

This obviously does not work:

my Num $x = 3.sqrt; my Buf $y = Buf.new($x)

Type check failed in initializing element #0 to Buf; expected uint8 but got
Num (1.7320508075688772e0)
   in block  at  line 1



You can convert the Num to a string and put that string into a Buf:

   Buf.new(3.sqrt.Str.encode)

That's what I'd do without any clue at all about who is supposed to use
this Buf. At least the buffer is about as long as the number is decimal
digits, which seems to be what you wanted?

Regards,
Tobias



Using Peter's code:

Buf.new(integer_root( 2, 3 * 100 ** 39 ).Str.encode)
Buf:0x<31 37 33 32 30 35 30 38 30 37 35 36 38 38 37 37 32 39 33 35 32 37 
34 34 36 33 34 31 35 30 35 38 37 32 33 36 36 39 34 32>


LAT AND LOTS OF repeatable NOISE!


--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: How do I handle Getopt::Long stray entries?

2020-05-14 Thread ToddAndMargo via perl6-users

On 2020-05-11 21:19, Peter Pentchev wrote:

#!/usr/bin/env raku

use v6.d;

use Getopt::Long;

sub cmd_install($cmd, Array[Str] :$enablerepo = [], Bool :$y = False, *@rest 
--> int)
{
say 'install';
dd $cmd;
dd @rest;
dd $enablerepo;
dd $y;
return 0;
}

sub cmd_list($cmd, Array[Str] :$enablerepo = [], *@rest --> int)
{
say 'list';
dd $cmd;
dd @rest;
dd $enablerepo;
return 42;
}

my %HANDLERS = (
install => &cmd_install,

# "list" doesn't care about the "-y" parameter, so skip it
list => -> $cmd, :$enablerepo = [], :$y = False, *@rest --> int {
cmd_list $cmd, :$enablerepo, |@rest
},
);

sub note-fatal(Str:D $msg)
{
$msg.note;
exit 1;
}

{
my $opts = get-options(
"enablerepo=s@",
"y",
);
CATCH { when Getopt::Long::Exception { .message.note; exit 1 } };
dd $opts;

note-fatal 'No command specified' unless $opts.elems;
my $cmd = $opts[0];
my $handler = %HANDLERS{$cmd};
note-fatal "Unknown command '$cmd'" unless $handler;
exit $handler(|$opts);
}



How do I use it?  Where are the options declared?

$ GetOptLongTest2.pl6
Capture $opts = \()
No command specified

$ GetOptLongTest2.pl6 --help
Unknown option help





--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: bash "."?

2020-05-15 Thread ToddAndMargo via perl6-users

On 2020-05-14 23:57, Shlomi Fish wrote:

(note that I comaintain it
now).



Then it will be awesome!

Thank yuo!


Re: bash "."?

2020-05-15 Thread ToddAndMargo via perl6-users

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 "."?

2020-05-15 Thread ToddAndMargo via perl6-users

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.


Rakudo Star 2020.05-rc2

2020-05-15 Thread p.spek via perl6-users
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: bash "."?

2020-05-15 Thread ToddAndMargo via perl6-users

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 "."?

2020-05-15 Thread ToddAndMargo via perl6-users

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 "."?

2020-05-15 Thread ToddAndMargo via perl6-users

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 "."?

2020-05-15 Thread ToddAndMargo via perl6-users




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

2020-05-15 Thread ToddAndMargo via perl6-users

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

2020-05-15 Thread ToddAndMargo via perl6-users

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

2020-05-15 Thread ToddAndMargo via perl6-users

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 "."?

2020-05-15 Thread ToddAndMargo via perl6-users

On 2020-05-15 17:26, Tom Browder wrote:
On Fri, May 15, 2020 at 13:47 ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:



 >> On 15 May 2020, at 20:08, ToddAndMargo via perl6-users
mailto:perl6-users@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


I need help with IO.e

2020-05-15 Thread ToddAndMargo via perl6-users

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
~~


Re: I need help with IO.e

2020-05-16 Thread ToddAndMargo via perl6-users

On 2020-05-15 22:30, ToddAndMargo via perl6-users wrote:

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




As far as I can tell IO.e and IO.d is completely trashed
in Windows:

K:\Windows\NtUtil>dir H:
 Volume in drive H is BACKUP
 Volume Serial Number is 00D0-CAD4

 Directory of H:\

05/15/2020  22:21 0 IAmBackup
05/15/2020  22:43  MyDocsBackup
   1 File(s)  0 bytes
   1 Dir(s)  29,638,656 bytes free



K:\Windows\NtUtil>raku "say 'h://IAmBackup'.IO.e"
Could not open say 'h://IAmBackup'.IO.e. Failed to stat file: no such 
file or di

rectory

K:\Windows\NtUtil>raku "say 'h:/IAmBackup'.IO.e"
Could not open say 'h:/IAmBackup'.IO.e. Failed to stat file: no such 
file or directory


K:\Windows\NtUtil>raku "say 'h:\IAmBackup'.IO.e"
Could not open say 'h:\IAmBackup'.IO.e. Failed to stat file: no such 
file or directory


K:\Windows\NtUtil>raku "say 'h:\\IAmBackup'.IO.e"
Could not open say 'h:\\IAmBackup'.IO.e. Failed to stat file: no such 
file or directory



And that goes for IO.d too:

K:\Windows\NtUtil>raku "say 'h:\\MyDocsBackup'.IO.d"
Could not open say 'h:\\MyDocsBackup'.IO.d. Failed to stat file: no such 
file or

 directory

K:\Windows\NtUtil>raku "say 'h:\MyDocsBackup'.IO.d"
Could not open say 'h:\MyDocsBackup'.IO.d. Failed to stat file: no such 
file or directory


K:\Windows\NtUtil>raku "say 'h:/MyDocsBackup'.IO.d"
Could not open say 'h:/MyDocsBackup'.IO.d. Failed to stat file: no such 
file or directory


K:\Windows\NtUtil>raku "say 'h://MyDocsBackup'.IO.d"
Could not open say 'h://MyDocsBackup'.IO.d. Failed to stat file: no such 
file or  directory


This gets a TRIPLE:  :'(  :'(  :'(



And it only works slightly better under Fedora:

$ p6 'say "GetOptLongTest.pl6".IO.e'
True

$ p6 'say "GetOptLongTest.pl7".IO.e'
False

$ p6 'say "p6lib".IO.d'
True

$ p6 'say "p7lib".IO.d'
Failed to find '/home/linuxutil/p7lib' while trying to do '.d'
  in block  at -e line 1

Notice that it crashed instead of returning a False.

This gets a single :'(

 AAHH 


Re: sqrt and Buf question

2020-05-16 Thread ToddAndMargo via perl6-users

On 2020-05-14 22:26, Peter Pentchev wrote:

And what is `2 * 100 ** 2000 `?  Is that `(2 x 100)^ 2000`
((2 times 100) to the 2000 power?

Point 1: exponentiation has a higher priority than multiplication.

Point 2:https://rosettacode.org/wiki/Integer_roots


Any chance of you answering the question directly?

Is it (2 x 100)^ 2000

Or 2 x ( 100^ 2000 )2 times (100 to the 2000 power)?

Your point 1 only applies if it is an exponent.  Is the
2000 an exponent?  Does ** stand for exponent?


Re: I need help with IO.e

2020-05-16 Thread ToddAndMargo via perl6-users

> Le sam. 16 mai 2020 à 12:16, ToddAndMargo via perl6-users
> mailto:perl6-users@perl.org>> a écrit :
>
> On 2020-05-15 22:30, ToddAndMargo via perl6-users wrote:
>  > 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
>  >
>
>
> As far as I can tell IO.e and IO.d is completely trashed
> in Windows:
>
> K:\Windows\NtUtil>dir H:
>Volume in drive H is BACKUP
>Volume Serial Number is 00D0-CAD4
>
>Directory of H:\
>
> 05/15/2020  22:21 0 IAmBackup
> 05/15/2020  22:43  MyDocsBackup
>  1 File(s)  0 bytes
>  1 Dir(s)  29,638,656 bytes free
>
>
>
> K:\Windows\NtUtil>raku "say 'h://IAmBackup'.IO.e"
> Could not open say 'h://IAmBackup'.IO.e. Failed to stat file: no such
> file or di
> rectory
>
> K:\Windows\NtUtil>raku "say 'h:/IAmBackup'.IO.e"
> Could not open say 'h:/IAmBackup'.IO.e. Failed to stat file: no such
> file or directory
>
> K:\Windows\NtUtil>raku "say 'h:\IAmBackup'.IO.e"
> Could not open say 'h:\IAmBackup'.IO.e. Failed to stat file: no such
> file or directory
>
> K:\Windows\NtUtil>raku "say 'h:\\IAmBackup'.IO.e"
> Could not open say 'h:\\IAmBackup'.IO.e. Failed to stat file: no such
> file or directory
>
>
> And that goes for IO.d too:
>
> K:\Windows\NtUtil>raku "say 'h:\\MyDocsBackup'.IO.d"
> Could not open say 'h:\\MyDocsBackup'.IO.d. Failed to stat file: no
> such
> file or
>directory
>
> K:\Windows\NtUtil>raku "say 'h:\MyDocsBackup'.IO.d"
> Could not open say 'h:\MyDocsBackup'.IO.d. Failed to stat file: 
no such

> file or directory
>
> K:\Windows\NtUtil>raku "say 'h:/MyDocsBackup'.IO.d"
> Could not open say 'h:/MyDocsBackup'.IO.d. Failed to stat file: 
no such

> file or directory
>
> K:\Windows\NtUtil>raku "say 'h://MyDocsBackup'.IO.d"
> Could not open say 'h://MyDocsBackup'.IO.d. Failed to stat file: no
> such
> file or  directory
>
> This gets a TRIPLE:  :'(  :'(  :'(
>
>
>
> And it only works slightly better under Fedora:
>
> $ p6 'say "GetOptLongTest.pl6".IO.e'
> True
>
> $ p6 'say "GetOptLongTest.pl7".IO.e'
> False
>
> $ p6 'say "p6lib".IO.d'
> True
>
> $ p6 'say "p7lib".IO.d'
> Failed to find '/home/linuxutil/p7lib' while trying to do '.d'
> in block  at -e line 1
>
> Notice that it crashed instead of returning a False.
>
> This gets a single :'(
>
>  AAHH 


> On 2020-05-16 04:29, Laurent Rosenfeld via perl6-users wrote:

Hi,

it should be:

$ raku *-e* "your one-liner script here"

Best regards,
Laurent.



Hi Laurent,

Excuse me a minute whilst I wipe some egg off my face.

mumble, mumble, mumble

Now it works


K:\Windows\NtUtil>raku -e "say 'h:/IAmBackup'.IO.e"
True

K:\Windows\NtUtil>raku -e "say 'h:/IAmNotBackup'.IO.e"
False

K:\Windows\NtUtil>raku -e "say 'h:\IAmBackup'.IO.e"
True

K:\Windows\NtUtil>raku -e "say 'h:\IAmNotBackup'.IO.e"
False


And `.d` is working better too:

K:\Windows\NtUtil>raku -e "say 'h:/MyDocsBackup'.IO.d"
True

K:\Windows\NtUtil>raku -e "say 'h:/NotMyDocsBackup'.IO.d"
Failed to find 'H:\NotMyDocsBackup' while trying to do '.d'
  in block  at -e line 1

But crashing instead of giving a False makes .d worthless.

Oh but .e works on directyories too:

K:\Windows\NtUtil>raku -e "say 'h:/NotMyDocsBackup'.IO.e"
False

K:\Windows\NtUtil>raku -e "say 'h:/MyDocsBackup'.IO.e"
True

so a workaround

And .d will work if you tack a Bool at the end:

K:\Windows\NtUtil>raku -e "say 'h:/NotMyDocsBackup'.IO.d.Bool"
False

K:\Windows\NtUtil>raku -e "say 'h:/MyDocsBackup'.IO.d.Bool"
True


Thank you for the second pair of eyes!

-T

it is way more fun when I am not the one at fault


Re: I need help with IO.e

2020-05-16 Thread ToddAndMargo via perl6-users

On 2020-05-16 05:34, Kevin Pye wrote:

The documentation for .d states:

Returns |True| if the invocant is a path that exists and is a directory. 
The method will |fail|  with 
|X::IO::DoesNotExist| if the path points to a non-existent filesystem 
entity.


(and by implication False if the file exists and is not a directory). In 
other words it is behaving exactly as specified.


If you want to allow for the possibility that the file does not exist at 
all, then you either need to catch the exception, or check for file 
existence first.


Something like
'p7lib'.IO ~~ :e & :d
might work, although I haven't tested it.

Kevin.



Hi Keven,

I had forgotten the -e in my Windows script
as I have it build in to my alias of P6 in Linux.
It was a real egg on the face moment.

From my point of view, IO.d giving True or crash
makes it pretty worthless.  But there are
two workaround:

IO.e also works on directories

And if you tack a .Bool on the end of IO.d it
gives you back a True or False

My notes from my perl6.IO.txt keeper:


Exists (directory):

   Warning: if you don't tack the Bool at the end, IO.d will return
True or Crash

   Note: IO.e also works on directories and is safer to use.

   DIRPATH.IO.d.Bool;
   if not $WorkingDir.IO.d.Bool { mkdir $WorkingDir, 0o766; }
   Note: do not use {} around the variable

   $ p6 'say "zef.git".IO.d.Bool;'
   True

   >raku -e "say 'h:/NotMyDocsBackup'.IO.d.Bool"
   False

   Workaround: send your command to a batch file and run the batch file


Exists (file):
   FILEPATH.IO.e
   if  $NewFileName.IO.e { $NewFileSize = $NewFileName.IO.s; } else 
{ return 4; }


   Note: IO.e.Bool misses hidden files
 https://github.com/rakudo/rakudo/issues/3594

 IO.e also works on directories



-T


Re: sqrt and Buf question

2020-05-16 Thread ToddAndMargo via perl6-users

On 2020-05-16 14:48, William Michels via perl6-users wrote:

Yes, ** stands for exponentiation


Thank you!


Re: I need help with IO.e

2020-05-16 Thread ToddAndMargo via perl6-users

On 2020-05-16 06:38, Peter Pentchev wrote:

$ raku *-e* "your one-liner script here"

And also you might want to put some quotes around the paths to let Raku
know that those are strings and not some identifiers or something.

G'luck,
Peter



Hi Peter,

This is what goofed me up:

$ alias p5
alias p5='perl -E'

$ alias p6
alias p6='perl6 -e'

I have no such feature on the Windows side and had
forgot about it.

Also, if you tack a .Bool on the end of IO.d, you
get back True or False, instead of the useless True
or Crash.  I updates my perl6.IO.txt keeper file.

And IO.e also works for directories

-T


Re: I need help with IO.e

2020-05-16 Thread ToddAndMargo via perl6-users

On 2020-05-16 17:44, Peter Pentchev wrote:

On Sat, May 16, 2020 at 03:19:05PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-16 06:38, Peter Pentchev wrote:

$ raku *-e* "your one-liner script here"

And also you might want to put some quotes around the paths to let Raku
know that those are strings and not some identifiers or something.

G'luck,
Peter



Hi Peter,

This is what goofed me up:

$ alias p5
alias p5='perl -E'

$ alias p6
alias p6='perl6 -e'

I have no such feature on the Windows side and had
forgot about it.

Also, if you tack a .Bool on the end of IO.d, you
get back True or False, instead of the useless True
or Crash.  I updates my perl6.IO.txt keeper file.

And IO.e also works for directories


What you're doing with "tacking .Bool at the end" is usually not
necessary to do explicitly, because most people do not "say" the result
of .d or .e, but use it in an if, for, while or some such conditional
statement, in which case Raku automatically converts the expression to
a boolean, i.e. tacks a .Bool at the end.

The reason .d and .e return a failure otherwise is that in some cases
they may be used not in a conditional statement, but as a kind of
assertion - "I really, really think that at this point this variable
should contain a valid path to an existing directory, but if something
went wrong in my program and the variable does not contain that, I do
not want the program to go on, it would be useless, I *want* it to raise
an exception when the value is used". At least that's what I think;
I *know* that the people who rewrote .IO in v6.d are on this list, so
please correct me if I'm wrong :)

But the most common use of .d, .e, .f and similar, the most common by
a very large margin, is in conditionals, where Raku does the conversion
to a boolean value automatically.

G'luck,
Peter



Hi Peter,

My big issues is that  want to check to see if something
is there, then take appropriate measures based on what
I am doing.  Crashing is not what I want.  If I should
exit based on what I find, I want the control over it.

In my "if" statements, I will use Bool anyway as it
will force the issue. And will alert me that there
is something else going on that I should be aware of
(fail).

Now I have to look up f.

Found it.  If you use the Bool, it returns a False
for directories.   Cool.

Thank you for the detailed explanation.  Very useful
and helpful!


Just out of curiosity

 https://docs.raku.org/routine/d
 (IO::Path) method d
 Defined as:

 method d(--> Bool:D)

 Returns True if the invocant is a path that
 exists and is a directory. The method will
 fail with X::IO::DoesNotExist if the path points to
 a non-existent filesystem entity.

Where in the definition
method d(--> Bool:D)
does it state True or Fail?  It states "Bool".  Is
something missing?

-T


How to find if a drive letter exists?

2020-05-17 Thread ToddAndMargo via perl6-users

Hi All,

Windows 7 & 10

I want to know if a drive letter exists:


K:\Windows\NtUtil>df -kPT
Filesystem   Type  1024-blocks  Used Available Capacity 
Mounted on

C:/Program Files/Git ntfs 40585620  15044068  25541552  38% /
D:   udf   5294394   5294394 0 100% /d
E:   ntfs 8188  3908  4280  48% /e
F:   ntfs10236  3908  6328  39% /f
J:   smbfs   951048868 514547660 436501208  55% /j
K:   smbfs   951048868 514547680 436501188  55% /k
L:   smbfs   951048868 514547700 436501168  55% /l

K:\Windows\NtUtil>dir e:
 Volume in drive E is DRIVERS
 Volume Serial Number is 44EB-5181

 Directory of E:\

File Not Found

This exists:
K:\Windows\NtUtil>raku -e "say 'H:'.IO.d.Bool;"
True

This does not:
K:\Windows\NtUtil>raku -e "say 'Z:'.IO.d.Bool;"
True


Many thanks,
-T


--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 01:23, Peter Pentchev wrote:

On Sat, May 16, 2020 at 06:57:53PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-16 17:44, Peter Pentchev wrote:

On Sat, May 16, 2020 at 03:19:05PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-16 06:38, Peter Pentchev wrote:

$ raku *-e* "your one-liner script here"

And also you might want to put some quotes around the paths to let Raku
know that those are strings and not some identifiers or something.

G'luck,
Peter



Hi Peter,

This is what goofed me up:

$ alias p5
alias p5='perl -E'

$ alias p6
alias p6='perl6 -e'

I have no such feature on the Windows side and had
forgot about it.

Also, if you tack a .Bool on the end of IO.d, you
get back True or False, instead of the useless True
or Crash.  I updates my perl6.IO.txt keeper file.

And IO.e also works for directories


What you're doing with "tacking .Bool at the end" is usually not
necessary to do explicitly, because most people do not "say" the result
of .d or .e, but use it in an if, for, while or some such conditional
statement, in which case Raku automatically converts the expression to
a boolean, i.e. tacks a .Bool at the end.

The reason .d and .e return a failure otherwise is that in some cases
they may be used not in a conditional statement, but as a kind of
assertion - "I really, really think that at this point this variable
should contain a valid path to an existing directory, but if something
went wrong in my program and the variable does not contain that, I do
not want the program to go on, it would be useless, I *want* it to raise
an exception when the value is used". At least that's what I think;
I *know* that the people who rewrote .IO in v6.d are on this list, so
please correct me if I'm wrong :)

But the most common use of .d, .e, .f and similar, the most common by
a very large margin, is in conditionals, where Raku does the conversion
to a boolean value automatically.

G'luck,
Peter



Hi Peter,

My big issues is that  want to check to see if something
is there, then take appropriate measures based on what
I am doing.  Crashing is not what I want.  If I should
exit based on what I find, I want the control over it.


So use .d in a boolean context (if, while, etc).


In my "if" statements, I will use Bool anyway as it
will force the issue. And will alert me that there
is something else going on that I should be aware of
(fail).


That's *exactly* the opposite of what I thought I explained, but
you do you, I guess.


Now I have to look up f.

Found it.  If you use the Bool, it returns a False
for directories.   Cool.


It is documented to return true for files, so yes, it would return false
for directories.


Thank you for the detailed explanation.  Very useful
and helpful!


Just out of curiosity

  https://docs.raku.org/routine/d
  (IO::Path) method d
  Defined as:

  method d(--> Bool:D)

  Returns True if the invocant is a path that
  exists and is a directory. The method will
  fail with X::IO::DoesNotExist if the path points to
  a non-existent filesystem entity.

Where in the definition
 method d(--> Bool:D)
does it state True or Fail?  It states "Bool".  Is
something missing?


The definition does not list all the exceptions that a method or
function can throw, and for good reason - people have learned their
lessons from the Java world, where this, while it did have some very
limited use, very quickly drove programmers to just say "... raises
Exception" on everything, making it essentially useless.

OK, in more words for people who may not have any Java programming
experience: they tried to make programmers list any exceptions that may
be raised from their methods, with the expectation that programmers
would check the documentation for any exceptions raised by the functions
and methods that they call, decide which ones they want to handle and
which ones they want to propagate upwards, and then list the ones that
they propatage and the ones that they raise themselves. However, in some
cases, like when using several library functions from several
third-party libraries, it turned out that the programmer said "oh come
on, I can't keep up with all the changes they make to their libraries,
they keep adding more and more exceptions; nah, I'll just say that my
method can throw *any* kind of exception under the Sun and be done with
it!".

Now Rust and Go are trying almost the same thing, but in a better way,
although I've seen the "propagate it, I don't care what it is!"
mentality  in both Rust ("just do .unwrap(), who cares") and Go ("is the
returned value an error? if so, return/propagate it, I don't care!")
programs (not all of them, of course).

I think that proper documentation is a better way than forcing
declarations of the errors retur

Re: How to find if a drive letter exists?

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 00:52, ToddAndMargo via perl6-users wrote:

Hi All,

Windows 7 & 10

I want to know if a drive letter exists:


K:\Windows\NtUtil>df -kPT
Filesystem   Type  1024-blocks  Used Available Capacity 
Mounted on

C:/Program Files/Git ntfs 40585620  15044068  25541552  38% /
D:   udf   5294394   5294394 0 100% /d
E:   ntfs 8188  3908  4280  48% /e
F:   ntfs    10236  3908  6328  39% /f
J:   smbfs   951048868 514547660 436501208  55% /j
K:   smbfs   951048868 514547680 436501188  55% /k
L:   smbfs   951048868 514547700 436501168  55% /l

K:\Windows\NtUtil>dir e:
  Volume in drive E is DRIVERS
  Volume Serial Number is 44EB-5181

  Directory of E:\

File Not Found

This exists:
K:\Windows\NtUtil>raku -e "say 'H:'.IO.d.Bool;"
True

This does not:
K:\Windows\NtUtil>raku -e "say 'Z:'.IO.d.Bool;"
True


Many thanks,
-T




Follow up:

Hi All,

Prince213 on the chat line helped me figure this out.

This is from my IO keeper:

Drive (letter) exists (Windows only):
   use `IO.e.Bool`

   # forward slashes
   >raku -e "say 'X:/'.IO.e.Bool;"
   False

   >raku -e "say 'D:/'.IO.e.Bool;"
   True

   >raku -e "say 'd:/'.IO.e.Bool;"
   True

   >raku -e "say 'Z:/'.IO.e.Bool;"
   False

   # back slashes
   >raku -e "say 'd:\\'.IO.e.Bool;"
   True

   >raku -e "say Q[d:\].IO.e.Bool;"
   True

   >raku -e "say Q[z:\].IO.e.Bool;"
   False


-T


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 02:30, Peter Pentchev wrote:

You said that you would tack Bool at the end in "if" statements, too.


Hi Peter,

No wonder.  I do not remember saying that, but I could
have.  My `if` statements look like:

   if not  "%Options".IO.d.Bool  {
  say "Creating %Options";
  mkdir( %Options", 0o777 );
   }

I definitely do not tack .Bool onto the end
of my `if` statements.

Thank you for your patience!

-T


Re: How to find if a drive letter exists?

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 07:47, Brad Gilbert wrote:

Why do you have `.Bool` on all of the `.e` tests?


Hi Brad,

I do this because it keeps me out of trouble.

I want back a yes or no answer, not True or Fail
(X::IO::DoesNotExist).

And I never remember which IO. will return
a True or Fail or which function (`if` does) will
convert X::IO::DoesNotExist to a False for me.

Plus it makes it more readable for me.
   [something].IO..Bool
tells me instantly I will be getting back a yes
or no answer.

So if you want to be a purist, you can experiment with
which IO. are going to give you a yes
or no answer or which functions will convert X::IO::DoesNotExist for 
you.  OR you can just tack .Bool

at the end and forgo the hair pulling.

Also the cryptograms in the documentation are not
correct.  For instance:

https://docs.raku.org/routine/d

method d(--> Bool:D)

Says it return a "Bool" not a "True" or "X::IO::DoesNotExist".
The modification to Bool is stated at the bottom of the page.

So, basically, it is to keeps me out of trouble.  And if
I am going to get `X::IO::DoesNotExist` back instead of
a Boolean, .Bool automatically converts it for me and
with no hair pulling.

So, basically, my LONG WINDED answer is that I do it for me.

-T


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 03:36, Peter Pentchev wrote:

On Sun, May 17, 2020 at 03:01:34AM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-17 02:30, Peter Pentchev wrote:

You said that you would tack Bool at the end in "if" statements, too.


Hi Peter,

No wonder.  I do not remember saying that, but I could
have.  My `if` statements look like:

if not  "%Options".IO.d.Bool  {
   say "Creating %Options";
   mkdir( %Options", 0o777 );
}

I definitely do not tack .Bool onto the end
of my `if` statements.


Uh. That's exactly what you're doing. You do *not* need the .Bool
there at the end. The "not" makes Raku convert whatever is there
to a boolean, so the .Bool is implicit. And if you were to check
the other way, if you had "if $foo.IO.d { ... }", then the "if"
makes Raku convert whatever is there to a boolean, so the .Bool is
implicit. You do not need to put the .Bool in an "if" or a "while"
statement.

G'luck,
Peter



Hi Peter,

Brad asked me the same thing on another thread.  This is what I
told him:

Hi Brad,

I do this because it keeps me out of trouble.

I want back a yes or no answer, not True or Fail
(X::IO::DoesNotExist).

And I never remember which IO. will return
a True or Fail or which functions (`if` does) will
convert X::IO::DoesNotExist to a False for me.

Plus it makes it more readable for me.
   [something].IO..Bool
tells me instantly I will be getting back a yes
or no answer.

So if you want to be a purist, you can experiment with
which IO. are going to give you a yes
or no answer or which functions will convert X::IO::DoesNotExist for 
you.  OR you can just tack .Bool

at the end and forgo the hair pulling.

Also the cryptograms in the documentation are not
correct.  For instance:

https://docs.raku.org/routine/d

method d(--> Bool:D)

Says it return a "Bool" not a "True" or "X::IO::DoesNotExist".
The modification to Bool is stated at the bottom of the page.

So, basically, it is to keeps me out of trouble.  And if
I am going to get `X::IO::DoesNotExist` back instead of
a Boolean, .Bool automatically converts it for me and
with no hair pulling.

So, basically, my LONG WINDED answer is that I do it for me.

-T


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 03:50, Elizabeth Mattijsen wrote:

[11:50:21]you don.t need the .Bool, .e already returns a Bool
[11:53:07]  sometimes IO.someletter returns True of Fail, not 
False.  Tacking .Bool on the end, means I don't have to remember which ones
[11:57:23]  True or Fail.  Typo
[11:58:21]A Failure is always false
[12:03:02]  A Fail is a lot more than that.  here is an example:  >raku -e 
"say Q[z:\].IO.d;"Failed to find 'Z:\' while trying to do '.d'  in block  at -e 
line 1
[12:04:16]  I use .bool at the end because I only want back a yes 
or no answer.  And I certainly don't want it to crash.  Always using .Bool keeps me 
out of trouble
[12:19:21]say "directory foo exists" if "foo".IO.d
[12:19:49]you don't have to worry about Failure then, which is 
the point of Failure to begin with
[12:23:33]  That is `if` converting the `X::IO::DoesNotExist` 
clutter into False for me.  I never know when that will happen and when it won't, so 
tacking .Bool at the end keeps me out of trouble.  I am not a purest here.  I do not 
mind seeing .Bool at the end.   It also tells me I will be seeing a Boolean.
[12:28:42]  bye bye for now. Thank you all for the tips!


Yup,  That is it.  Keep me from having to pull my hair out.


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 13:04, Peter Pentchev wrote:

On Sun, May 17, 2020 at 12:12:51PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-17 03:36, Peter Pentchev wrote:

On Sun, May 17, 2020 at 03:01:34AM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-17 02:30, Peter Pentchev wrote:

You said that you would tack Bool at the end in "if" statements, too.


Hi Peter,

No wonder.  I do not remember saying that, but I could
have.  My `if` statements look like:

 if not  "%Options".IO.d.Bool  {
say "Creating %Options";
mkdir( %Options", 0o777 );
 }

I definitely do not tack .Bool onto the end
of my `if` statements.


Uh. That's exactly what you're doing. You do *not* need the .Bool
there at the end. The "not" makes Raku convert whatever is there
to a boolean, so the .Bool is implicit. And if you were to check
the other way, if you had "if $foo.IO.d { ... }", then the "if"
makes Raku convert whatever is there to a boolean, so the .Bool is
implicit. You do not need to put the .Bool in an "if" or a "while"
statement.

G'luck,
Peter



Hi Peter,

Brad asked me the same thing on another thread.  This is what I
told him:

Hi Brad,

I do this because it keeps me out of trouble.

I want back a yes or no answer, not True or Fail
(X::IO::DoesNotExist).

And I never remember which IO. will return
a True or Fail or which functions (`if` does) will
convert X::IO::DoesNotExist to a False for me.


OK, so I promise to the group that this is my last message on this
particular topic :)

Todd, you won't have to remember anything if you *only* use .IO.d and
.IO.e and all the rest the way the rest of the world uses them: *only*
in conditional statements. Your examples could have been written as:

 raku -e "say 'yes' if 'h:/'.IO.d"

...and you would not have to remember anything except that .IO.d, .e,
.f, and the rest of these predicates only need to be used in
conditionals. This covers 'if', 'while', and it also covers stuff like
"my $final-decision = $path.IO.d and $path.IO.w", since this is also
using the predicates in a sort of a conditional statement. Basically,
in any *real-world* situation where you'd want to use them, you don't
need the explicit conversion to boolean.

Hope that helps.

G'luck,
Peter



Hi Peter,

Very true.

Although

   "say 'yes' if 'h:/'.IO.d"

is obscure to me and

   "say 'h:/'.IO.d.Bool"

is very easy for me to understand.

And since I am the one who is going to have to
maintain this code in perpetuity, maintainability
comes before everything else.  EVEN IF I have to
tell Raku to do something explicitly that it will
do for me on the fly.  It is all about me being
able to go into the code 5 days or 5 years
from now and being able to figure out what I did.

I had to convert a Perl 5 sub over and oh my goodness
the hoops I had to jump thought in Perl 5 that and
so very simplified in Raku.

Perl 5 does have the bad reputation of being a write
only language. (It is, only if you let it be.)

I likes Perl 5.  I ADORE Perl 6

-T

p.s. you are a wonderful teacher.  Do you have a
teaching background?


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 14:43, ToddAndMargo via perl6-users wrote:

Although

    "say 'yes' if 'h:/'.IO.d"

is obscure to me and

    "say 'h:/'.IO.d.Bool"

is very easy for me to understand.



Hi Peter,

I think it would help if you knew how my
mind worked.

`if` to me is a Boolean function.  If this
expressions is true, do this, if not, do
something else.

This is what happens to me when I see expressions
like

"say 'yes' if 'h:/'.IO.d"

if the expression (h:/.IO.d) is true, then
say the result of the expression test, not the
result from the expression.  I have to figure
out what the results from the expression are
and why it is passing or failing the test.

Two steps in my mind.  Not that I can't figure
things like this out, I just don't like the effort,
when it can be avoided.  The way I look at it, the
time it takes me to write five extra letters (.Bool)
will save me ten times that amount of time trying to
figure out what I did 5 days or 5 years from now.
Dr. Demming (Quality circles, Kaisen, etc.) makes
a very strong point of this

And `if` can actually be very helpful at times:
   if  $x ~~ s/ "abc" /def/ {...;}
will tell you if the regex actually found "abc".
This I adore because I know is a test.  Not
in the least bit obscure.

.d is suppose to return a Boolen, but does not.
Some functions will convert the junk for you on
the fly.  Raku is very friendly this way.  Five extra
letters and I do not have to wonder who does what
to whom.

Yes, I am a bit weird.

Thank you for all the wonderful explanations!  Very
much appreciated.

-T


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 20:28, Paul Procacci wrote:

So tack a .Bool at the end.
You are coercing a bool to a bool by doing so and hopefully the 
optimizer is smart enough for people who like to be redundant.


;)


Hi Paul,

Especially when I can never remember when IO.someletter
will return a full True or False Boolean and when it
will return a True or a useless text message.

The optimizer should have a lot of fun with me!  Works
darned well too!

-T


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 21:19, ToddAndMargo via perl6-users wrote:

On 2020-05-17 20:28, Paul Procacci wrote:

So tack a .Bool at the end.
You are coercing a bool to a bool by doing so and hopefully the 
optimizer is smart enough for people who like to be redundant.


;)


Hi Paul,

Especially when I can never remember when IO.someletter
will return a full True or False Boolean and when it
will return a True or a useless text message.

The optimizer should have a lot of fun with me!  Works
darned well too!

-T


Speaking of optimizer, it would be interesting to see
if my coercing a half a Bool and a useless text message
to a True of False when analyzed takes  more of less
optimizing than giving it a straight Boolean to start with.

But now I are getting at some really deep trivia


Re: How to find if a drive letter exists?

2020-05-17 Thread ToddAndMargo via perl6-users

Follow up:

When I go to maintain this thing in five days or five
years and I have one of those "what the h*** is IO.d.Bool
suppose to mean?" moments, I created the follow subs to make the code 
more readable/maintainable.


And mind you I can always look up what IO.d.Bool means
in my own IO documentation, but this makes it human readable.
Saving a lot of time.  Plus, since I program in Top Down,
I call all three of these all over the place in this program:


sub DirectoryExists( Str $DirPath --> Bool ) { return 
"$DirPath".IO.d.Bool; }  # $Full DirPath format is `H:\MyDocsBackup`


sub DriveExists( Str $DriveLetter --> Bool ) { return 
"$DriveLetter".IO.e.Bool; }  # $Drive Letter format is `A:\`


sub FileExists(  Str $FilePath--> Bool ) { return 
"$FilePath".IO.f.Bool; } # $File Path format is `H:\IAmBackup`



   if not  "%Options".IO.e.Bool {..}

versus

   if not  DriveExists( %Options ) {...}

And it is instantly understandable at a glance.  Put
a little extra effort up front and downstream is a
lot easier.

Also, I adore using `not` in place of False and not equal
as it is more human readable.

:-)

-T

We will let the optimizer take care of any of
my unneeded coercing.


Re: How to find if a drive letter exists?

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 21:56, ToddAndMargo via perl6-users wrote:

Follow up:


Thank you for all the help figuring all this out!


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 21:48, Paul Procacci wrote:
You can check this yourself by looking at the QAST nodes after the 
static analyzer has had its fill:


# diff -u <(perl6 --target=optimize -e '"test".IO.e') <(perl6 
--target=optimize -e '"test".IO.e.Bool')


Huh.  Not sure what I am looking at


$ diff -u <(perl6 --target=optimize -e 'say if "test".IO.d') <(perl6 
--target=optimize -e 'say "test".IO.d.Bool')

===SORRY!=== Error while compiling -e
Unsupported use of bare "say"; in Raku please use .say if you meant to 
call it as a method on $_, or use an explicit invocant or argument, or 
use &say to refer to the function as a noun

at -e:1
--> say⏏ if "test".IO.d
--- /dev/fd/63  2020-05-17 22:01:37.947790677 -0700
+++ /dev/fd/62  2020-05-17 22:01:37.948790659 -0700
@@ -0,0 +1,98 @@
+- QAST::CompUnit  :W :UNIT :CAN_LOWER_TOPIC
+  [pre_deserialize]
+- QAST::Stmt
+  - QAST::Stmt
+- QAST::Op(loadbytecode)
+  - QAST::VM
+[moar]
+  - QAST::SVal(ModuleLoader.moarvm)
+[jvm]
+  - QAST::SVal(ModuleLoader.class)
+[js]
+  - QAST::SVal(ModuleLoader)
+- QAST::Op(callmethod load_module)
+  - QAST::Op(gethllsym)
+- QAST::SVal(nqp)
+- QAST::SVal(ModuleLoader)
+  - QAST::SVal(Perl6::ModuleLoader)
+  - QAST::Op(forceouterctx)
+- QAST::BVal(2)
+- QAST::Op(callmethod load_setting)
+  - QAST::Op(getcurhllsym)
+- QAST::SVal(ModuleLoader)
+  - QAST::SVal(CORE.d)
+  [post_deserialize]
+- QAST::Stmts
+  - QAST::Op(bind)
+- QAST::Var(attribute $!do)
+  - QAST::WVal(Block)
+  - QAST::WVal(Code)
+- QAST::BVal(1)
+- QAST::Op(bindcurhllsym)
+  - QAST::SVal(GLOBAL)
+  - QAST::WVal(GLOBAL)
+  [load]
+- QAST::Op(call)
+  - QAST::BVal(2)
+  [children]
+- QAST::Block(:cuid(2))  :in_stmt_mod say \"test\".IO.d.Bool
+│ - QAST::Var(local __args__ :decl(param))
+│ - QAST::Stmts  say \"test\".IO.d.Bool
+│ - QAST::Op(call)
+│   - QAST::Block(:cuid(1) :blocktype(declaration_static)) 
:outer :in_stmt_mod :code_object :IN_DECL

+│   │ - QAST::Stmts  say \"test\".IO.d.Bool
+│   │   - QAST::Var(lexical $¢ :decl(contvar))
+│   │   - QAST::Var(lexical $! :decl(contvar))
+│   │   - QAST::Var(lexical $/ :decl(contvar))
+│   │   - QAST::Op(null)
+│   │   - QAST::Var(lexical GLOBALish :decl(static))
+│   │   - QAST::Var(lexical EXPORT :decl(static))
+│   │   - QAST::Var(lexical $?PACKAGE :decl(static))
+│   │   - QAST::Var(lexical ::?PACKAGE :decl(static))
+│   │   - QAST::Var(lexical $=finish :decl(static))
+│   │   - QAST::Var(lexical $=pod :decl(static))
+│   │ [value]
+│   │   -
+│   │   - QAST::Var(lexical !UNIT_MARKER :decl(static))
+│   │ - QAST::Stmts
+│   │   - QAST::Op(bind)
+│   │ - QAST::Var(local ctxsave :decl(var))
+│   │ - QAST::Var(contextual $*CTXSAVE)
+│   │   - QAST::Op(unless)
+│   │ - QAST::Op(isnull)
+│   │   - QAST::Var(local ctxsave)
+│   │ - QAST::Op(if)
+│   │   - QAST::Op(can)
+│   │ - QAST::Var(local ctxsave)
+│   │ - QAST::SVal(ctxsave)
+│   │   - QAST::Op(callmethod ctxsave)
+│   │ - QAST::Var(local ctxsave)
+│   │ - QAST::Stmts
+│   │   - QAST::WVal(Array)
+│   │   - QAST::Stmt  say \"test\".IO.d.Bool
+│   │ - QAST::Want 
+│   │   - QAST::Op(callstatic &say)  :statement_id<1> say 
\"test\".IO.d.Bool

+│   │ - QAST::Op(hllize) 
+│   │   - QAST::Op(callmethod Bool)  Bool
+│   │ - QAST::Op(hllize) 
+│   │   - QAST::Op(callmethod d)  d
+│   │ - QAST::Op(hllize) 
+│   │   - QAST::Op(callmethod IO)  IO
+│   │ - QAST::Want  test
+│   │   - QAST::WVal(Str)
+│   │   - Ss
+│   │   - QAST::SVal(test)
+│   │   - v
+│   │   - QAST::Op(p6sink)
+│   │ - QAST::Op(callstatic &say)  :statement_id<1> 
say \"test\".IO.d.Bool

+│   │   - QAST::Op(hllize) 
+│   │ - QAST::Op(callmethod Bool)  Bool
+│   │   - QAST::Op(hllize) 
+│   │ - QAST::Op(callmethod d)  d
+│   │   - QAST::Op(hllize) 
+│   │ - QAST::Op(callmethod IO)  IO
+│   │   - QAST::Want  test
+│   │ - QAST::WVal(Str)
+│   │ - Ss
+│   │ - QAST::SVal(test)
+│   │   - QAST::WVal(Nil)


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-17 22:28, Paul Procacci wrote:
Don't 'say' anything.  Just let the optimizer spit out the QAST that you 
are interested in looking at.

The following spits out a diff after optimization:

# diff -u <(perl6 --target=optimize -e '"test".IO.e') <(perl6 
--target=optimize -e '"test".IO.e.Bool')


 >> Huh.  Not sure what I am looking at

You aren't specific.  Is it the error message you received because you 
used 'say' improperly or is it the QAST?

- How to use 'say' is in the documentation.
- A QAST is pretty close to an AST and I'd start there on wikipedia or 
something.


I was looking for the difference between

'say if "test".IO.d',  and
'say "test".IO.d.Bool'

This is were 'if" has to unscramble a "True" or
"text message" return.

But, I have no idea what all that stuff is that comes
back anyway, so I think I will give up.

Thank you for all the help!

-T


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 13:28, Tom Browder wrote:
On Mon, May 18, 2020 at 14:36 ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


On 2020-05-17 22:28, Paul Procacci wrote:

...

'say if "test".IO.d',  and
'say "test".IO.d.Bool'


Try:

'say so "test".IO.d'



I have mo clue that this says



$ diff -u <(perl6 --target=optimize -e 'so if "test".IO.d') <(perl6 
--target=optimize -e 'so "test".IO.d.Bool')

===SORRY!=== Error while compiling -e
Undeclared routine:
if used at line 1

WARNINGS for -e:
Useless use of "so " in expression "so \"test\".IO.d.Bool" in sink 
context (line 1)

--- /dev/fd/63  2020-05-18 14:17:32.731286061 -0700
+++ /dev/fd/62  2020-05-18 14:17:32.732286043 -0700
@@ -0,0 +1,98 @@
+- QAST::CompUnit  :W :UNIT :CAN_LOWER_TOPIC
+  [pre_deserialize]
+- QAST::Stmt
+  - QAST::Stmt
+- QAST::Op(loadbytecode)
+  - QAST::VM
+[moar]
+  - QAST::SVal(ModuleLoader.moarvm)
+[jvm]
+  - QAST::SVal(ModuleLoader.class)
+[js]
+  - QAST::SVal(ModuleLoader)
+- QAST::Op(callmethod load_module)
+  - QAST::Op(gethllsym)
+- QAST::SVal(nqp)
+- QAST::SVal(ModuleLoader)
+  - QAST::SVal(Perl6::ModuleLoader)
+  - QAST::Op(forceouterctx)
+- QAST::BVal(2)
+- QAST::Op(callmethod load_setting)
+  - QAST::Op(getcurhllsym)
+- QAST::SVal(ModuleLoader)
+  - QAST::SVal(CORE.d)
+  [post_deserialize]
+- QAST::Stmts
+  - QAST::Op(bind)
+- QAST::Var(attribute $!do)
+  - QAST::WVal(Block)
+  - QAST::WVal(Code)
+- QAST::BVal(1)
+- QAST::Op(bindcurhllsym)
+  - QAST::SVal(GLOBAL)
+  - QAST::WVal(GLOBAL)
+  [load]
+- QAST::Op(call)
+  - QAST::BVal(2)
+  [children]
+- QAST::Block(:cuid(2))  :in_stmt_mod so \"test\".IO.d.Bool
+│ - QAST::Var(local __args__ :decl(param))
+│ - QAST::Stmts  so \"test\".IO.d.Bool
+│ - QAST::Op(call)
+│   - QAST::Block(:cuid(1) :blocktype(declaration_static)) 
:outer :in_stmt_mod :code_object :IN_DECL

+│   │ - QAST::Stmts  so \"test\".IO.d.Bool
+│   │   - QAST::Var(lexical $¢ :decl(contvar))
+│   │   - QAST::Var(lexical $! :decl(contvar))
+│   │   - QAST::Var(lexical $/ :decl(contvar))
+│   │   - QAST::Op(null)
+│   │   - QAST::Var(lexical GLOBALish :decl(static))
+│   │   - QAST::Var(lexical EXPORT :decl(static))
+│   │   - QAST::Var(lexical $?PACKAGE :decl(static))
+│   │   - QAST::Var(lexical ::?PACKAGE :decl(static))
+│   │   - QAST::Var(lexical $=finish :decl(static))
+│   │   - QAST::Var(lexical $=pod :decl(static))
+│   │ [value]
+│   │   -
+│   │   - QAST::Var(lexical !UNIT_MARKER :decl(static))
+│   │ - QAST::Stmts
+│   │   - QAST::Op(bind)
+│   │ - QAST::Var(local ctxsave :decl(var))
+│   │ - QAST::Var(contextual $*CTXSAVE)
+│   │   - QAST::Op(unless)
+│   │ - QAST::Op(isnull)
+│   │   - QAST::Var(local ctxsave)
+│   │ - QAST::Op(if)
+│   │   - QAST::Op(can)
+│   │ - QAST::Var(local ctxsave)
+│   │ - QAST::SVal(ctxsave)
+│   │   - QAST::Op(callmethod ctxsave)
+│   │ - QAST::Var(local ctxsave)
+│   │ - QAST::Stmts
+│   │   - QAST::WVal(Array)
+│   │   - QAST::Stmt  so \"test\".IO.d.Bool
+│   │ - QAST::Want 
+│   │   - QAST::Op(callstatic &prefix:)  
:statement_id<1> so

+│   │ - QAST::Op(hllize) 
+│   │   - QAST::Op(callmethod Bool)  Bool
+│   │ - QAST::Op(hllize) 
+│   │   - QAST::Op(callmethod d)  d
+│   │ - QAST::Op(hllize) 
+│   │   - QAST::Op(callmethod IO)  IO
+│   │ - QAST::Want  test
+│   │   - QAST::WVal(Str)
+│   │   - Ss
+│   │   - QAST::SVal(test)
+│   │   - v
+│   │   - QAST::Op(p6sink)
+│   │ - QAST::Op(callstatic &prefix:)  
:statement_id<1> so

+│   │   - QAST::Op(hllize) 
+│   │ - QAST::Op(callmethod Bool)  Bool
+│   │   - QAST::Op(hllize) 
+│   │ - QAST::Op(callmethod d)  d
+│   │   - QAST::Op(hllize) 
+│   │ - QAST::Op(callmethod IO)  IO
+│   │   - QAST::Want  test
+│   │ - QAST::WVal(Str)
+│   │ - Ss
+│   │ - QAST::SVal(test)
+│   │   - QAST::WVal(Nil)


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 14:22, Peter Pentchev wrote:

Please note that in my example a couple of messages ago I did not write
"say if 'h:/'.IO.d", I wrote "say 'yes' if 'h:/'.IO.d". The difference
is very important and leads directly to the error-like message you got.



Hi Peter,

I as interested in the .d difference, so I put that
in instead.

But it does not matter.  I can't tell what I am looking at
so it does not matter anyway

Thank you for all the wonderful help!

-T


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 14:35, Peter Pentchev wrote:

My point is that you put a bare "say" without telling it*what*  to say,
which does something quite specific in both Perl and Raku. That should,
at least, explain the error-like message.

G'luck,
Peter


What I was after was to see what impact I had coercing a
Bool to a Bool verses coercing a half a Bool and unless
text message to a Bool.

But, you know, I am using a (very) high lever language
for a reason.  I can get to the final product twice as
fast.  If I wanted to optimize the use of my CPU, I would
program in C, or if I was REALLY masochistic, I program
in Assembly.  (Done that, don't want to do it again!)

So my little coercing Bool to Bool so I do not have to
remember which IO.soemletter is or is not returning an
actual Boolean is a mute point.  I am already wasting
a ton of CPU by being in a high level language to start with.

And I don't care.  My computer is a bazillion times more powerful than 
any thing I waste on a high level language.

It hardly notices my "indiscretion"

An gee wiz, Raku is a TON more human readable than C,
which gives me a migraine if I stare at it too long.
Raku is far more maintainable.  But that is just my opinion


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 15:38, Peter Pentchev wrote:

On Mon, May 18, 2020 at 03:18:26PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-18 14:35, Peter Pentchev wrote:

My point is that you put a bare "say" without telling it*what*  to say,
which does something quite specific in both Perl and Raku. That should,
at least, explain the error-like message.

G'luck,
Peter


What I was after was to see what impact I had coercing a
Bool to a Bool verses coercing a half a Bool and unless
text message to a Bool.

[snip another explanation of why you use .Bool, which I already
  said that I am not commenting on; my point is something entirely
  different]

All I was trying to say was to explain that "say if something" and
"say 'foo' if something" do different things, to answer your question
from a previous message why "say if something" told you something
about undefined values. That's all I was trying to help you with :)

G'luck,
Peter



I got it.  I was only rambling on.  I tend to do that.


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 15:44, Tom Browder wrote:
On Mon, May 18, 2020 at 16:19 ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


On 2020-05-18 13:28, Tom Browder wrote:

...

 > Try:
 >
 > 'say so "test".IO.d'


Todd, you didn't try what I suggested. Once again, look a the line above^^

There is no "if" there.

-Tom



It was the "if" I was interested in.  "if" has to change
a True or "useless text message" into a True or False.

Anyway, since I don't understand anything that came
back, I am going to give up.

And besides, any extra work I am giving the compiler
with my coercing a Bool into a Bool so I don't
remember which IO.someletter give back an actual
Boolean and which ones don't, is SWAMPED by my use
of a high level language.  This is not Assembly.


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 16:01, Tom Browder wrote:

Since you don't like to listen to advice I give up.


Tom!

I listen to your advice ALL-THE-TIME.  I was
just interested in something else.  And when I did
not understand the result, your way or my way,
I abandoned the effort, especially since I did not
need the information.  It was just a curiosity.

Don't for a second think I do not value your advice!

-T


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

In 2020-05-18 16:11, Peter Pentchev wrote:

As an exercise for the reader: once the above sinks in, what exactly
will "say if 'h:/'.IO.d" do?


It returns the the result of the expression that
"if" evaluated.

I do know all this.  It is easier for me to read
the other way.


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 17:14, Peter Pentchev wrote:

On Mon, May 18, 2020 at 04:53:31PM -0700, ToddAndMargo via perl6-users wrote:

In 2020-05-18 16:11, Peter Pentchev wrote:

As an exercise for the reader: once the above sinks in, what exactly
will "say if 'h:/'.IO.d" do?


It returns the the result of the expression that
"if" evaluated.


OK, so why does it give you an error message if you run it? :)

Not quite.

 say if 'h:/'.IO.d

...is equivalent to:

 if 'h:/'.IO.d {
 say;
 }

which would have been valid in Perl (apart from the parentheses
around the condition of the "if", Raku allows you to omit those), but
it is not valid Raku. Run it and see what it says.

Once again you thought that "if" returns a value. "If" does not return
a value, it is not a function, it is a statement. Just the same as "for"
does not return a value, and "while" does not return a value.

G'luck,
Peter



Hi Peter,

Of course!  I am not arguing with anyone that
they are not right!

I am doing what I am doing to make things easier for
me to read in the future.  Since I am already using
a very high level language, what is one more affront
to my CPU?

:-)

-T


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 22:58, ToddAndMargo via perl6-users wrote:

On 2020-05-18 17:14, Peter Pentchev wrote:
On Mon, May 18, 2020 at 04:53:31PM -0700, ToddAndMargo via perl6-users 
wrote:

In 2020-05-18 16:11, Peter Pentchev wrote:

As an exercise for the reader: once the above sinks in, what exactly
will "say if 'h:/'.IO.d" do?


It returns the the result of the expression that
"if" evaluated.


OK, so why does it give you an error message if you run it? :)

Not quite.

 say if 'h:/'.IO.d

...is equivalent to:

 if 'h:/'.IO.d {
 say;
 }

which would have been valid in Perl (apart from the parentheses
around the condition of the "if", Raku allows you to omit those), but
it is not valid Raku. Run it and see what it says.

Once again you thought that "if" returns a value. "If" does not return
a value, it is not a function, it is a statement. Just the same as "for"
does not return a value, and "while" does not return a value.

G'luck,
Peter



Hi Peter,

Of course!  I am not arguing with anyone that
they are not right!

I am doing what I am doing to make things easier for
me to read in the future.  Since I am already using
a very high level language, what is one more affront
to my CPU?

:-)

-T


Peter,

I am not a full time programmer.  I am I.T. support
to small busienses.  Programming is only about 10
to 20% of what I do.  Wednesday, I get to fix an
sql server installer that things it is being given
the wrong (speaking) language.  I DO EVERYTHING !!!

The things I write MUST be maintainable.  When I go back
to them, I won't remember everything on the fly.  EVEN
THOUGH I have copous notes and HOW TOs.

If you want me to change my wicked way, come up with
something even more understandable, human readable
"on the fly".

And with the talent you have already displayed, I know
you can.  You are very, very good at this stuff.

:-)

-T


Re: I need help with IO.e

2020-05-22 Thread ToddAndMargo via perl6-users

On 2020-05-19 05:17, Peter Pentchev wrote:


...control structures, I mean.

G'luck,
Peter



No problem,

I appreciate all the help!

:-)

-T


Tip: erase an array

2020-05-23 Thread ToddAndMargo via perl6-users

Hi All,

How to erase an array is missing from the docs.  I just
open a case on it:

https://github.com/Raku/doc/issues/3423


In the mean time, to erase/empty an array:

@x = Empty;
@x = ();

Both work.  `Empty` is a bit more human readable

:-)

-T


I need help sorting a list

2020-05-24 Thread ToddAndMargo via perl6-users

Hi All,

https://docs.raku.org/routine/sort

I need help sorting a list.

This is the list of values I want to sort:

H:\MyDocsBackup\backup1
H:\MyDocsBackup\backup2
H:\MyDocsBackup\backup126
H:\MyDocsBackup\backup3
H:\MyDocsBackup\backup33
H:\MyDocsBackup\backup6


This is what I want back:

H:\MyDocsBackup\backup1
H:\MyDocsBackup\backup2
H:\MyDocsBackup\backup3
H:\MyDocsBackup\backup6
H:\MyDocsBackup\backup33
H:\MyDocsBackup\backup126


This is how I did it in Perl 5, but I can't
figure out what I did!  :'(  :'(  :'(

@Sorted_List = sort {
   my @a = split /.*\D/, $a;
   my @b = split /.*\D/, $b; $a[1] <=> $b[1]; } @Unsorted_List;


Many thanks,
-T


Re: I need help sorting a list

2020-05-24 Thread ToddAndMargo via perl6-users




On 24 May 2020, at 10:43, ToddAndMargo via perl6-users  
wrote:

Hi All,

https://docs.raku.org/routine/sort

I need help sorting a list.

This is the list of values I want to sort:

H:\MyDocsBackup\backup1
H:\MyDocsBackup\backup2
H:\MyDocsBackup\backup126
H:\MyDocsBackup\backup3
H:\MyDocsBackup\backup33
H:\MyDocsBackup\backup6


This is what I want back:

H:\MyDocsBackup\backup1
H:\MyDocsBackup\backup2
H:\MyDocsBackup\backup3
H:\MyDocsBackup\backup6
H:\MyDocsBackup\backup33
H:\MyDocsBackup\backup126


This is how I did it in Perl 5, but I can't
figure out what I did!  :'(  :'(  :'(

@Sorted_List = sort {
   my @a = split /.*\D/, $a;
   my @b = split /.*\D/, $b; $a[1] <=> $b[1]; } @Unsorted_List;


Many thanks,
-T


On 2020-05-24 02:24, Elizabeth Mattijsen wrote:
> dd .sort: { m/ \d+ $/ }
>

Hi Elizabeth,

This seems to work:

   $ raku -e 'dd .sort: { m/ \d+ $/ };'
   ("a5", "a6", "a33", "a111").Seq


But I can't figure out how to get it into an array:

   $ raku -e 'my @x=.sort: { m/ \d+ $/ }; for @x { 
say $_; }'

   a5
   a2
   a123
   a133
   a1

:'(

-T


Re: I need help sorting a list

2020-05-24 Thread ToddAndMargo via perl6-users

On 2020-05-24 13:13, Tobias Boege wrote:

On Sun, 24 May 2020, ToddAndMargo via perl6-users wrote:

On 2020-05-24 02:24, Elizabeth Mattijsen wrote:

dd .sort: { m/ \d+ $/ }



Hi Elizabeth,

This seems to work:

$ raku -e 'dd .sort: { m/ \d+ $/ };'
("a5", "a6", "a33", "a111").Seq


But I can't figure out how to get it into an array:

$ raku -e 'my @x=.sort: { m/ \d+ $/ }; for @x { say
$_; }'
a5
a2
a123
a133
a1



I think getting it into an array is not the problem, you did the
right thing by assigning the Seq into @x. The sort characteristic
that Liz used, { m/ \d+ $/ }, doesn't do the right thing (at least
for me). I cannot tell you why it is an apparent no-op, though.

Converting the extracted Match to an Int does work:

   $ raku -e 'my @x = .sort: { +m/ \d+ $/ }; dd @x'
   Array @x = ["a1", "a2", "a5", "a22", "a123", "a133"]

Regards,
Tobias




Hi Tobias,

$ raku -e 'my @x = .sort: { +m/ \d+ $/ }; dd @x; 
for @x {say $_;}'

Array @x = ["a1", "a2", "a5", "a22", "a133", "a155"]
a1
a2
a5
a22
a133
a155


Yippee!!!

Thank you!
-T


Re: I need help sorting a list

2020-05-24 Thread ToddAndMargo via perl6-users

On 2020-05-24 15:07, Tobias Boege wrote:

On Sun, 24 May 2020, Elizabeth Mattijsen wrote:

Hmmm... it appears we need to numerify the match to get numeric comparison semantics, so 
we put a "+" before the match:

$ raku -e 'my @x=.sort: { +m/ \d+ $/ }; for @x { say $_; }'
a1
a2
a5
a123
a133



So I think this would be a more general "version sort" then, where the number
doesn't have to be at the end only:

   @things.sort: {
   .comb(/ \d+ | \D+ /)
   .map({ .Int // .self })
   }

It does not conform to all the rules about natural sort on Rosetta Code [1]
but I like how

   - longest-token matching,
   - .sort behavior on (differently-sized) tuples, and
   - .Int returning an (undefined) Failure

work together here.

Regards,
Tobias

[1] https://rosettacode.org/wiki/Natural_sorting




$ raku -e 'my @things = .sort; dd @things; for 
@things {say $_;}'

Array @things = ["a1", "a123", "a133", "a2", "a22", "a5"]
a1
a123
a133
a2
a22
a5



:'(


Re: I need help sorting a list

2020-05-24 Thread ToddAndMargo via perl6-users

On 2020-05-24 15:39, ToddAndMargo via perl6-users wrote:

On 2020-05-24 15:07, Tobias Boege wrote:

On Sun, 24 May 2020, Elizabeth Mattijsen wrote:
Hmmm... it appears we need to numerify the match to get numeric 
comparison semantics, so we put a "+" before the match:


$ raku -e 'my @x=.sort: { +m/ \d+ $/ }; for @x { 
say $_; }'

a1
a2
a5
a123
a133



So I think this would be a more general "version sort" then, where the 
number

doesn't have to be at the end only:

   @things.sort: {
   .comb(/ \d+ | \D+ /)
   .map({ .Int // .self })
   }

It does not conform to all the rules about natural sort on Rosetta 
Code [1]

but I like how

   - longest-token matching,
   - .sort behavior on (differently-sized) tuples, and
   - .Int returning an (undefined) Failure

work together here.

Regards,
Tobias

[1] https://rosettacode.org/wiki/Natural_sorting




$ raku -e 'my @things = .sort; dd @things; for 
@things {say $_;}'

Array @things = ["a1", "a123", "a133", "a2", "a22", "a5"]
a1
a123
a133
a2
a22
a5



:'(



Ooops.  Ignore that last comment


This is with what Tobias actually said

my @things = .sort: { .comb(/ \d+ | \D+ /) 
.map({ .Int // .self })}; for @things {say $_;}

a1
a2
a5
a22
a123
a133

my @things = .sort: { .comb(/ \d+ | \D+ /) 
.map({ .Int // .self })}; dd @things; for @things {say $_;}

Array @things = ["a1", "a2", "a5", "a22", "a133", "b123"]
a1
a2
a5
a22
a133
b123


Re: I need help sorting a list

2020-05-24 Thread ToddAndMargo via perl6-users

On 2020-05-24 15:51, Patrick R. Michaud wrote:

On Mon, May 25, 2020 at 12:07:22AM +0200, Tobias Boege wrote:

   @things.sort: {
   .comb(/ \d+ | \D+ /)
   .map({ .Int // .self })
   }



Or how about even somethig like

@things.sort: *.Version;

which does handle a reasonable set of version semantics...?

(The .Version method was apparently added in 2020.01.)

Pm




   my @things = .sort: *.Version; dd @things; 
for @things {say $_;}

   Array @things = ["a1", "a2", "a5", "a22", "a133", "b123"]
   a1
   a2
   a5
   a22
   a133
   b123


I like it!


I do not understand method":"

2020-05-25 Thread ToddAndMargo via perl6-users

Hi All,

Looking at the following:

> my @things = .sort: *.Version; dd 
@things; for @things {say $_;}


Array @things = ["a1b33", "a1", "a2rc2", "a2.3", "a5.1", "b1a23"]

a1b33
a1
a2rc2
a2.3
a5.1
b1a23

Other than not quite getting the alpha, beta, and
release candidate thing down, I do not understand:

.sort: *.Version

1) What does the `:` do?

2) Why the space?

3) What does the `*` do?

4) Is the dot before Version mean something other
than .Version being a method?

Yours in confusion,
-T


Re: I do not understand method":"

2020-05-25 Thread ToddAndMargo via perl6-users
On Mon, May 25, 2020 at 1:24 PM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


Hi All,

Looking at the following:

  > my @things = .sort: *.Version; dd
@things; for @things {say $_;}

Array @things = ["a1b33", "a1", "a2rc2", "a2.3", "a5.1", "b1a23"]

a1b33
a1
a2rc2
a2.3
a5.1
b1a23

Other than not quite getting the alpha, beta, and
release candidate thing down, I do not understand:

.sort: *.Version

1) What does the `:` do?

2) Why the space?

3) What does the `*` do?

4) Is the dot before Version mean something other
than .Version being a method?

Yours in confusion,
-T



On 2020-05-25 14:00, Brad Gilbert wrote:


In the following the 「:」 makes it so you don't need parenthesis

     (…).sort: …

     (…).sort(…)

The reason there needs to be a space is so it isn't confused for an adverb.

「*.Version」 is a method call turned into a lambda.
Basically it creates a lambda where the only thing it does is call a 
method named 「Version」


A 「*」 where a term is expected is an instance of Whatever.

If you use that with an operator it becomes a WhateverCode lambda.

     sub say-the-type ( $_ ) {
       say .^name
     }

     say-the-type  *;  # Whatever

     say -the-type *.method; # WhateverCode





Hi Brad,

Thank you!

So the same as
> my @things = <5 2 1 33 22>.sort( *.Version )
[1 2 5 22 33]


Why don't these two work?  Or at least give the
wrong answer.  I thought Version was a method.

> my @things = <5 2 1 33 22>.sort.Version
No such method 'Version' for invocant of type 'Seq'
  in block  at  line 1

> my @things = <5 2 1 33 22>.Version.sort
No such method 'Version' for invocant of type 'List'
  in block  at  line 1


What is a "lambda" λ?

-T


RakudoStar-2020.05 just hit

2020-05-25 Thread ToddAndMargo via perl6-users

Hot off the presses:

RakudoStar-2020.05.1.01-win-x86_64-(JIT).msi

:-)


Re: I do not understand method":"

2020-05-25 Thread ToddAndMargo via perl6-users

On 2020-05-25 14:00, Brad Gilbert wrote:

In the following the 「:」 makes it so you don't need parenthesis


You have created a monster!

> my $s="a:c"; say $s.index: ":"
1

:-)


I need a second pair of eyes

2020-05-25 Thread ToddAndMargo via perl6-users

HI All,

I am missing something here:


154:   # figure out the label
155:   say %CommandLine;
156:   if "%CommandLine".starts-with( "[" )  &&
157:  "%CommandLine".contains( "]" ) {


BACKUP:\MyDocsBackup\backup1
Cannot resolve caller index(Str:U: Str:D); none of these signatures match:
(List:D: Cool:D $needle, *%_)
(Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ 
--> Int:D)

(Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Int:D)
(Cool:D: Cool:D $needle, *%_ --> Int:D)
(Cool:D: Cool:D $needle, Cool:D $pos, :i(:$ignorecase)!, 
:m(:$ignoremark), *%_ --> Int:D)

(Cool:D: Cool:D $needle, Cool:D $pos, :m(:$ignoremark)!, *%_ --> Int:D)
(Cool:D: Cool:D $needle, Cool:D $pos, *%_ --> Int:D)
(Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> 
Int:D)
(Str:D: Str:D $needle, Int:D $pos, :i(:$ignorecase)!, 
:m(:$ignoremark), *%_ --> Int:D)

(Str:D: @needles, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> Int:D)
(Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Int:D)
(Str:D: Str:D $needle, Int:D $pos, :m(:$ignoremark)!, *%_ --> Int:D)
(Str:D: @needles, :m(:$ignoremark)!, *%_ --> Int:D)
(Str:D: Str:D $needle, *%_ --> Int:D)
(Str:D: Str:D $needle, Int:D $pos, *%_ --> Int:D)
(Str:D: @needles, *%_ --> Int:D)
  in sub GatherOptions at CobianWrapper.pl6 line 156
  in block  at CobianWrapper.pl6 line 390


Rakudo Star 2020.05

2020-05-26 Thread p.spek via perl6-users
Good day Rakoons!

After two release candidates for 2020.05, I'm happy to announce that Rakudo
Star is getting its official 2020.05 release.

With help from hankache on the Windows side of things, we have gotten no
reports of issues that prevent anyone from using this release. The files can be
found at the following URLs:

Rakudo Star tarballs (GNU+Linux, *BSD, Mac):

- https://rakudo.org/dl/star/rakudo-star-2020.05.tar.gz
- https://rakudo.org/dl/star/rakudo-star-2020.05.tar.gz.asc
- https://rakudo.org/dl/star/rakudo-star-2020.05.tar.gz.checksums.txt

Rakudo Star installer (Windows):

- https://rakudo.org/dl/star/rakudo-star-2020.05.1-01-win-x86_64-(JIT).msi
- https://rakudo.org/dl/star/rakudo-star-2020.05.1-01-win-x86_64-(JIT).msi.asc
- 
https://rakudo.org/dl/star/rakudo-star-2020.05.1-01-win-x86_64-(JIT).msi.sha256.txt

If you have comments or issues, please let us know on the mailing list!

-- 
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: I need a second pair of eyes

2020-05-26 Thread ToddAndMargo via perl6-users

> On Tue, May 26, 2020, 09:45 ToddAndMargo via perl6-users
> mailto:perl6-users@perl.org>> wrote:
>
> HI All,
>
> I am missing something here:
>
>
> 154:   # figure out the label
> 155:   say %CommandLine;
> 156:   if "%CommandLine".starts-with( "[" )  &&
> 157:  "%CommandLine".contains( "]" ) {
>
>
> BACKUP:\MyDocsBackup\backup1
> Cannot resolve caller index(Str:U: Str:D); none of these
> signatures match:
>   (List:D: Cool:D $needle, *%_)
>   (Cool:D: Cool:D $needle, :i(:$ignorecase)!,
> :m(:$ignoremark), *%_
> --> Int:D)
>   (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Int:D)
>   (Cool:D: Cool:D $needle, *%_ --> Int:D)
>   (Cool:D: Cool:D $needle, Cool:D $pos, :i(:$ignorecase)!,
> :m(:$ignoremark), *%_ --> Int:D)
>   (Cool:D: Cool:D $needle, Cool:D $pos, :m(:$ignoremark)!,
> *%_ --> Int:D)
>   (Cool:D: Cool:D $needle, Cool:D $pos, *%_ --> Int:D)
>   (Str:D: Str:D $needle, :i(:$ignorecase)!,
> :m(:$ignoremark), *%_ -->
> Int:D)
>   (Str:D: Str:D $needle, Int:D $pos, :i(:$ignorecase)!,
> :m(:$ignoremark), *%_ --> Int:D)
>   (Str:D: @needles, :i(:$ignorecase)!, :m(:$ignoremark), *%_
> --> Int:D)
>   (Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Int:D)
>   (Str:D: Str:D $needle, Int:D $pos, :m(:$ignoremark)!, *%_
> --> Int:D)
>   (Str:D: @needles, :m(:$ignoremark)!, *%_ --> Int:D)
>   (Str:D: Str:D $needle, *%_ --> Int:D)
>   (Str:D: Str:D $needle, Int:D $pos, *%_ --> Int:D)
>   (Str:D: @needles, *%_ --> Int:D)
> in sub GatherOptions at CobianWrapper.pl6 line 156
> in block  at CobianWrapper.pl6 line 390
On 2020-05-25 23:58, Veesh Goldman wrote:


Actually, in my tests it works fine. You have to show more code.

On Tue, May 26, 2020, 09:49 Veesh Goldman <mailto:rabbive...@gmail.com>> wrote:


I would guess it's because you interpolated your variables into a
string. Try it without the quotes.
To be more helpful, I'd need a MWE.


I originally did not have the quotes in it.  Removing the
again seems to get past the error.  I must be gettng tired.

Thank you for the assist.  It was afraid of you!

:-)


Re: I need a second pair of eyes

2020-05-26 Thread ToddAndMargo via perl6-users

This is Rakudo version 2020.05.1 built on MoarVM version 2020.05
implementing Raku 6.d.

It is back at it again.  The second test, I sent it
something with brackets in it.  It is the failed test
to goes wonkers


I put some debugging and is seems that it does not like
my `&&`


155: say %CommandLine;

156: if %CommandLine.starts-with( "[" )  {say 
"Yes";}else{say "No";}


157: if %CommandLine.contains( "]" )  {say "Yes";}else{say 
"No";}


158: if %CommandLine.starts-with( "[" )  &&
  %CommandLine.contains( "]" ) {


155: A:\YourDocs\backup1 
156: No 


 157: No

   158: Cannot resolve caller 
index(Str:U: Str:D); none of these signatures match: 
 (List:D: Cool:D $needle, *%_) 



...
in sub GatherOptions at CobianWrapper.pl6 line 158


Re: I need a second pair of eyes

2020-05-26 Thread ToddAndMargo via perl6-users

On 2020-05-26 01:37, ToddAndMargo via perl6-users wrote:
155: A:\YourDocs\backup1 
     156: No

  157: No

    158: Cannot resolve caller 
index(Str:U: Str:D); none of these signatures match: 
  (List:D: Cool:D $needle, *%_)



I wonder what that was all about.  Looked fine on my screen:

155: A:\YourDocs\backup1
156: No
157: No

158: Cannot resolve caller
index(Str:U: Str:D); none of these signatures match:
...
(List:D: Cool:D $needle, *%_)
in sub GatherOptions at CobianWrapper.pl6 line 158


I need help testing for Nil

2020-05-26 Thread ToddAndMargo via perl6-users

Hi All,

How do I turn this:

$ raku -e 'my $x="abc"; say $x.index( "q" );'
Nil

into a test?

$ raku -e 'my $x="abc"; if $x.index( "q" ) eq Nil {say "Nil"}else{say 
"Exists";}'

Use of Nil in string context
  in block  at -e line 1
Use of Nil in string context
  in block  at -e line 1
Nil


Many thanks,
-T


Re: I need a second pair of eyes

2020-05-26 Thread ToddAndMargo via perl6-users

On 2020-05-26 01:40, ToddAndMargo via perl6-users wrote:

On 2020-05-26 01:37, ToddAndMargo via perl6-users wrote:
155: A:\YourDocs\backup1 
 156: No

  157: No

    158: Cannot resolve caller 
index(Str:U: Str:D); none of these signatures match: 
  (List:D: Cool:D $needle, *%_)



I wonder what that was all about.  Looked fine on my screen:

155: A:\YourDocs\backup1
156: No
157: No

158: Cannot resolve caller
index(Str:U: Str:D); none of these signatures match:
...
(List:D: Cool:D $needle, *%_)
in sub GatherOptions at CobianWrapper.pl6 line 158



This passes with flying colors:

#!/usr/bin/env raku
my Str $x = "abc";
if $x.starts-with( "[" )  &&
   $x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }



GGGR


Re: I need help testing for Nil

2020-05-26 Thread ToddAndMargo via perl6-users
On Tue, May 26, 2020 at 4:24 PM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


Hi All,

How do I turn this:

$ raku -e 'my $x="abc"; say $x.index( "q" );'
Nil

into a test?

$ raku -e 'my $x="abc"; if $x.index( "q" ) eq Nil {say "Nil"}else{say
"Exists";}'
Use of Nil in string context
in block  at -e line 1
Use of Nil in string context
in block  at -e line 1
Nil


Many thanks,
-T



On 2020-05-26 15:00, Brad Gilbert wrote:

Generally you don't need to test for 「Nil」.
You can just test for defined-ness.


True enough



     $ raku -e 'my $x="abc"; with $x.index( "q" ) {say "Exists"} else 
{say "Nil";}'


Also 「Nil」 is not a 「Str」, so why would you use 「eq」?


Because == did not work



     $ raku -e 'Nil.Str'
     Use of Nil in string context

If you really need to check specifically for 「Nil」 (which you probably 
don't), then you can use 「===」.


     for Str, Int, Nil {
         say 'Nil' if $_ === Nil;
     }

The 「//」 operator can also be useful to deal with undefined values such 
as 「Nil」.


     my $x = 'abc';
     say $x.index('q') // 'cannot find the index of 「q」';




Hi Brad,

Did not know about the triple =

Thank you!

-T


$ raku -e 'my $x="abc"; if $x.index( "q" ) === Nil {say "Nil"}else{say 
"Exists";}'

Nil

$ raku -e 'my $x="abc"; if $x.index( "a" ) === Nil {say "Nil"}else{say 
"Exists";}'

Exists

And I found buried in my Nil notes that `=:=` works too

$ raku -e 'my $x="abc"; if $x.index( "q" ) =:= Nil {say "Nil"}else{say 
"Exists";}'

Nil

$ raku -e 'my $x="abc"; if $x.index( "b" ) =:= Nil {say "Nil"}else{say 
"Exists";}'

Exists


Re: I need a second pair of eyes

2020-05-26 Thread ToddAndMargo via perl6-users
On Tue, May 26, 2020 at 4:54 PM yary <mailto:not@gmail.com>> wrote:


 From this much

158: Cannot resolve caller
index(Str:U: Str:D); none of these signatures match:

"index" is being called with the 1st arg undefined, 2nd arg defined.
There is no "index" multi handling the 1st undefined arg, is my guess.

-y


On Tue, May 26, 2020 at 4:41 AM ToddAndMargo via perl6-users
mailto:perl6-users@perl.org>> wrote:

On 2020-05-26 01:37, ToddAndMargo via perl6-users wrote:
 > 155: A:\YourDocs\backup1
 >  156: No
 >   157: No
 >
 > 158: Cannot resolve caller
 > index(Str:U: Str:D); none of these signatures match:
 >   (List:D: Cool:D $needle, *%_)


I wonder what that was all about.  Looked fine on my screen:

155: A:\YourDocs\backup1
156: No
157: No

158: Cannot resolve caller
index(Str:U: Str:D); none of these signatures match:
...
(List:D: Cool:D $needle, *%_)
in sub GatherOptions at CobianWrapper.pl6 line 158





On 2020-05-26 15:15, Brad Gilbert wrote:

This is more of how I would structure it

     with %CommandLine {
         .say;
         # if /^ '['  .*? ']' / {
        if .starts-with('[') && .contains(']') {
             ...
         }
     } else {
         say 'no backup path given'
     }

We can skip checking 「.starts-with」 and 「.contains」 if there isn't 
anything to start with.


Hi Brad.  That got me past the error.  Thank you!


need string is not a a string is a string help

2020-05-26 Thread ToddAndMargo via perl6-users

Hi All,

What in the dickens  Only `say  %Options;` works,
but only when it only has a single argument.


241: for split( "", %Options ) -> $y {say "$y = ", ord( $y ) };
242: for %Options.comb -> $y {say "$y = ", ord( $y ) };
243: say  %Options;
244: say ">" ~ %Options ~ "<";
245: print "-->" ~ %Options ~ "<--\n";
246: say %Options.^name;
247: say %Options.WHAT;
248: dd  %Options;
249: say %Options.ends-with( "1" );
250: say  %Options.chars;



241: & 242: no output to screen
243: A:\YourDocs\backup1
 # I did not put this blank line here
244: ><
245: --><--
246: Str
247: (Str)
248: Str %Options = ""
249: False   # DOES TOO END IN A ONE!!!
250: 0

I am so confused!

-T


Re: I need help testing for Nil

2020-05-26 Thread ToddAndMargo via perl6-users

On 2020-05-26 16:29, Brad Gilbert wrote:

There are various equality operators.

「==」 Tests for numeric equality
「eq」 Tests for string equality
「===」 Tests for value identity
「=:=」 Tests for pointer equality (Note that it looks a bit like 「:=」)
「eqv」 Tests for structure equivalence.

The 「==」 and 「eq」 operators are special because they force their values 
to be numbers or strings before they do anything else.


Thank you!  Wrote it down.


Re: need string is not a a string is a string help

2020-05-26 Thread ToddAndMargo via perl6-users

On 2020-05-26 17:13, ToddAndMargo via perl6-users wrote:

Hi All,

What in the dickens  Only `say  %Options;` works,
but only when it only has a single argument.


241: for split( "", %Options ) -> $y {say "$y = ", ord( $y ) };
242: for %Options.comb -> $y {say "$y = ", ord( $y ) };
243: say  %Options;
244: say ">" ~ %Options ~ "<";
245: print "-->" ~ %Options ~ "<--\n";
246: say %Options.^name;
247: say %Options.WHAT;
248: dd  %Options;
249: say %Options.ends-with( "1" );
250: say  %Options.chars;



241: & 242: no output to screen
243: A:\YourDocs\backup1
  # I did not put this blank line here
244: ><
245: --><--
246: Str
247: (Str)
248: Str %Options = ""
249: False   # DOES TOO END IN A ONE!!!
250: 0

I am so confused!

-T



Figured it out.  %Options.comb never had anything actually in it. 
Why the first "say" said it did is

beyond me.


Re: I need a second pair of eyes

2020-05-26 Thread ToddAndMargo via perl6-users

On 2020-05-25 23:42, ToddAndMargo via perl6-users wrote:

HI All,

I am missing something here:


154:   # figure out the label
155:   say %CommandLine;
156:   if "%CommandLine".starts-with( "[" )  &&
157:  "%CommandLine".contains( "]" ) {


BACKUP:\MyDocsBackup\backup1
Cannot resolve caller index(Str:U: Str:D); none of these signatures match:
     (List:D: Cool:D $needle, *%_)
     (Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ 
--> Int:D)

     (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Int:D)
     (Cool:D: Cool:D $needle, *%_ --> Int:D)
     (Cool:D: Cool:D $needle, Cool:D $pos, :i(:$ignorecase)!, 
:m(:$ignoremark), *%_ --> Int:D)
     (Cool:D: Cool:D $needle, Cool:D $pos, :m(:$ignoremark)!, *%_ --> 
Int:D)

     (Cool:D: Cool:D $needle, Cool:D $pos, *%_ --> Int:D)
     (Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> 
Int:D)
     (Str:D: Str:D $needle, Int:D $pos, :i(:$ignorecase)!, 
:m(:$ignoremark), *%_ --> Int:D)

     (Str:D: @needles, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> Int:D)
     (Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Int:D)
     (Str:D: Str:D $needle, Int:D $pos, :m(:$ignoremark)!, *%_ --> Int:D)
     (Str:D: @needles, :m(:$ignoremark)!, *%_ --> Int:D)
     (Str:D: Str:D $needle, *%_ --> Int:D)
     (Str:D: Str:D $needle, Int:D $pos, *%_ --> Int:D)
     (Str:D: @needles, *%_ --> Int:D)
   in sub GatherOptions at CobianWrapper.pl6 line 156
   in block  at CobianWrapper.pl6 line 390



Follow up:

This turned ot the be the same issue as the other on:

say %CommandLine;
BACKUP:\MyDocsBackup\backup1

Was not the actual case.  %CommandLine
was actually blank.

I need to start using `print` instead of `say` to
proof things.

Thank you all for the help and tips!


Re: I need a second pair of eyes

2020-05-26 Thread ToddAndMargo via perl6-users

On 2020-05-26 19:16, ToddAndMargo via perl6-users wrote:

On 2020-05-25 23:42, ToddAndMargo via perl6-users wrote:

HI All,

I am missing something here:


154:   # figure out the label
155:   say %CommandLine;
156:   if "%CommandLine".starts-with( "[" )  &&
157:  "%CommandLine".contains( "]" ) {


BACKUP:\MyDocsBackup\backup1
Cannot resolve caller index(Str:U: Str:D); none of these signatures 
match:

 (List:D: Cool:D $needle, *%_)
 (Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ 
--> Int:D)

 (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Int:D)
 (Cool:D: Cool:D $needle, *%_ --> Int:D)
 (Cool:D: Cool:D $needle, Cool:D $pos, :i(:$ignorecase)!, 
:m(:$ignoremark), *%_ --> Int:D)
 (Cool:D: Cool:D $needle, Cool:D $pos, :m(:$ignoremark)!, *%_ --> 
Int:D)

 (Cool:D: Cool:D $needle, Cool:D $pos, *%_ --> Int:D)
 (Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ 
--> Int:D)
 (Str:D: Str:D $needle, Int:D $pos, :i(:$ignorecase)!, 
:m(:$ignoremark), *%_ --> Int:D)
 (Str:D: @needles, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> 
Int:D)

 (Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Int:D)
 (Str:D: Str:D $needle, Int:D $pos, :m(:$ignoremark)!, *%_ --> Int:D)
 (Str:D: @needles, :m(:$ignoremark)!, *%_ --> Int:D)
 (Str:D: Str:D $needle, *%_ --> Int:D)
 (Str:D: Str:D $needle, Int:D $pos, *%_ --> Int:D)
 (Str:D: @needles, *%_ --> Int:D)
   in sub GatherOptions at CobianWrapper.pl6 line 156
   in block  at CobianWrapper.pl6 line 390



Follow up:

This turned ot the be the same issue as the other on:

say %CommandLine;
BACKUP:\MyDocsBackup\backup1

Was not the actual case.  %CommandLine
was actually blank.

I need to start using `print` instead of `say` to
proof things.

Thank you all for the help and tips!



And I replaced all my "say" with "print"


Re: I need a second pair of eyes

2020-05-27 Thread ToddAndMargo via perl6-users

On 2020-05-26 23:39, Peter Pentchev wrote:

On Tue, May 26, 2020 at 07:16:54PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-25 23:42, ToddAndMargo via perl6-users wrote:

HI All,

I am missing something here:


154:   # figure out the label
155:   say %CommandLine;
156:   if "%CommandLine".starts-with( "[" )  &&
157:  "%CommandLine".contains( "]" ) {


BACKUP:\MyDocsBackup\backup1

[snip]



Follow up:

This turned ot the be the same issue as the other on:

say %CommandLine;
BACKUP:\MyDocsBackup\backup1

Was not the actual case.  %CommandLine
was actually blank.

I need to start using `print` instead of `say` to
proof things.

Thank you all for the help and tips!


This is... strange. Are you really, really sure that the "say" and
the "print" were really used on the same variable with the same value?
And the value is supposed to be a (possibly undefined) string?
And when the value is an undefined string (and nothing changes it after
"say" is called on it), "say" outputs something that looks like
a valid path?

This would be really, really strange. I'd say it would qualify as a bug,
unless there is something else happening there.

Are you really, really, really sure that there is nothing between
the call to "say" and the place where you use the variable that could
change the value? Are you also really, really, really sure that you have
not mistyped one of the names? If so, is there a way you could create
a minimal example, a short program that, when run on your system, always
behaves this way, and post it (attach the source file, don't retype it)
in full, so that people can try to run it on their systems and see if
"say" really does something strange?

G'luck,
Peter



Hi Peter,

What you saw is what I had.  Originally, I
thought I just need a second pair of eyes
and that I thought I saw what I saw, which
does happen to me more times than I would like
to admit.

What tipped me off was when I put a second
duplicate (copy and paste) say line right under
the first and the second one returned nothing.
This made me go back and look at how I populated
the variable in question and I found I had made
several mistakes and, indeed, the variable was
blank.

The value say gave, where it was suppose to give
a blank, was actually a value collected from the
run line that was used to populate the variable
in question.

The real bugger is that when things like this
happen, my first suspicion is that it is me doing
something wrong and 99% of the time that is the
case, so I had no idea this would be a Raku issue.
I wasted a lot of time chasing the wrong rabbit
down the wrong hole.

Oh ya, and good luck reproducing this for the
developers.

-T


Re: I need a second pair of eyes

2020-05-27 Thread ToddAndMargo via perl6-users

On 2020-05-27 07:27, Brad Gilbert wrote:

The point was that 「say」 will print undefined values without complaining.

Really debug statements should be more like:

$*STDERR.put: 「%CommandLine = 」, %CommandLine;

Or more succinctly:

dd %CommandLine;




Which does bring to the forefront, why a duplicate
copy and paste of the same say line, one on
top of the other, first delivered a value from
another variable and the second one gave the correct
value.

I have converted to this say free sort of stuff;

   if  %Options< Debug >  {
  print "   ParentDir = <$ParentDir>\n";
  print "   NumBackups <$NumBackups>  Rotates %Options< Rotates >\n";
  print "   Sorted List   = [" ~ @Sorted_List ~ "]\n";
  print "   Ordered List  = [" ~ @Ordered_List ~ "]\n";
  print "   Rotated List  = [" ~ @Rotated_List ~ "]\n";
  print "   Reverse List  = [" ~ @Reverse_Pruned_List ~ "]\n";
  print "   Reverse_Pruned List = [" ~ @Reverse_Pruned_List ~ "]\n";
  print "   Number of backup directories is $NumBackups\n\n";
   }


I like dd if I am interested in the structure of a variable
but avoid it if only the value is of interest.

And I could never in a million years be able to
duplicate this issue for the developers


Re: I need a second pair of eyes

2020-05-27 Thread ToddAndMargo via perl6-users

On 2020-05-27 13:38, Veesh Goldman wrote:
well, like I said before, if you just show ALL of your code, then we'd 
be able to know what happened.


I fixed the mistake I made, which also fixed the
wrong output from "say", so all is working now
and I doubt the issue would reproduce.

The code itself is 420 lines long, plus modules.
Would you like me to eMail you the code and
all the modules?  I am no sure what you can do
with it.


I reproduced one of the errors!

2020-05-27 Thread ToddAndMargo via perl6-users

I managed to reproduce one of the errors I was getting.
I specifically did not initialize $x.  If I do, the
error goes away.  In my code, I did a "say $x" and it
said $x had something in it.  That is what threw me off


K:\Windows\NtUtil>raku -v
This is Rakudo version 2020.05.1 built on MoarVM version
2020.05 implementing Raku 6.d.



#!/usr/bin/env raku
my Str $x;
if $x.starts-with( "[" )  &&
   $x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }



K:\Windows\NtUtil>raku Contains.Test.pl6
Cannot resolve caller starts-with(Str:U: Str:D); none of these 
signatures match


(Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ 
--> Bool)

(Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
(Cool:D: Cool:D $needle, *%_ --> Bool)
(Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> 
Bool)

(Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
(Str:D: Str:D $needle, *%_ --> Bool)
  in block  at Contains.Test.pl6 line 3


The function should just complain that the variable is
not initialized.



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: I need a second pair of eyes

2020-05-27 Thread ToddAndMargo via perl6-users

On 2020-05-27 14:26, Will Coleda wrote:

Part of framing the question in the first place is reducing the
problem code to as small a subset as possible that still exhibits the
problem.


AND THEY ALWAYS WORK!     !

No reporting that back to the developers.


Often, in the course of doing this "golfing", you'll uncover the
problem yourself.


Very true.

Usually, I will go back and rewrite the thing as
human readable as possible, and low and behold, it
will start working and I have no clue what was wrong
with the original code.

I have when you have to go back and try and find a
single quote you accidentally copied and pasted from
a one liner test


Re: I reproduced one of the errors!

2020-05-27 Thread ToddAndMargo via perl6-users

On 2020-05-27 14:32, Andy Bach wrote:

#!/usr/bin/env raku
my Str $x;
if $x.starts-with( "[" )  &&
$x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }

K:\Windows\NtUtil>raku Contains.Test.pl6
Cannot resolve caller starts-with(Str:U: Str:D); none of these
signatures match

(Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_
--> Bool)
(Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
(Cool:D: Cool:D $needle, *%_ --> Bool)
(Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ -->
Bool)
(Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
(Str:D: Str:D $needle, *%_ --> Bool)
in block  at Contains.Test.pl6 line 3

 > The function should just complain that the variable is not initialized.





Well, it is:
Cannot resolve caller starts-with(Str:U: Str:D);
...
in block  at Contains.Test.pl6 line 3

it says:
For line 3:
if $x.starts-with( "[" )
looking for a possible method 'starts-with' with a signature of 2 
params; an undefined string ('Str:U:') and a defined one ('Str:D:') 
failed - here's the list of the possible signatures raku currently has ..."


I'd not be surprise if you could write your own "starts-with(Str:U: 
Str:D); " method in raku and take care of this.  You could probably even 
have it "say"
You have an undefined String var in this call, not going to be able to 
do much useful matching against that.  Did you forget to initialize 
something?


Hi Andy,

The function should just complain that you need to feed it an
initialized value instead of sending you on a wild goose chase,

In that snippet, I deliberately did not initialize the variable
to trigger the weird behavior.

When I first encountered this error, I was testing a similar
uninitialized variable.  I thought it was populated because "say" said 
so.  "say" just had some shadow of another variable I had used to 
populate the uninitialized variable.


The value looked correct.  I spend a lot of time chasing
the wrong rabbit down the wrong rabbit hole.

-T


Re: bash "."?

2020-05-29 Thread ToddAndMargo via perl6-users

On 2020-05-28 06:47, Tom Browder wrote:
On Fri, May 15, 2020 at 20:38 ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


On 2020-05-15 17:26, Tom Browder wrote:
 > On Fri, May 15, 2020 at 13:47 ToddAndMargo via perl6-users
 > mailto:perl6-users@perl.org>
<mailto:perl6-users@perl.org <mailto:perl6-users@perl.org>>> wrote:


Did you look at Raku modules:

    Config::INI
    Config
    ...

Go to modules.raku.org <http://modules.raku.org> and search for "config".

-Tom


Just looked.  it is crashing on me!  I will open another
question on it.


Re: I reproduced one of the errors!

2020-05-29 Thread ToddAndMargo via perl6-users

On 2020-05-28 06:39, Peter Pentchev wrote:

On Wed, May 27, 2020 at 03:12:01PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-27 14:32, Andy Bach wrote:

#!/usr/bin/env raku
my Str $x;
if $x.starts-with( "[" )  &&
$x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }

K:\Windows\NtUtil>raku Contains.Test.pl6
Cannot resolve caller starts-with(Str:U: Str:D); none of these
signatures match

(Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_
--> Bool)
(Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
(Cool:D: Cool:D $needle, *%_ --> Bool)
(Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ -->
Bool)
(Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
(Str:D: Str:D $needle, *%_ --> Bool)
in block  at Contains.Test.pl6 line 3

  > The function should just complain that the variable is not initialized.





Well, it is:
Cannot resolve caller starts-with(Str:U: Str:D);
...
in block  at Contains.Test.pl6 line 3

it says:
For line 3:
if $x.starts-with( "[" )
looking for a possible method 'starts-with' with a signature of 2
params; an undefined string ('Str:U:') and a defined one ('Str:D:')
failed - here's the list of the possible signatures raku currently has
..."

I'd not be surprise if you could write your own "starts-with(Str:U:
Str:D); " method in raku and take care of this.  You could probably even
have it "say"
You have an undefined String var in this call, not going to be able to
do much useful matching against that.  Did you forget to initialize
something?


Hi Andy,

The function should just complain that you need to feed it an
initialized value instead of sending you on a wild goose chase,


It does say that you are trying to call "starts-with()" as a method on
a value of type Str:U (undefined string), and it cannot find such
a method. It also tells you what methods it can find.

It gives the same error message no matter what types the function/method
can handle and no matter what type you are trying to call it on.
 From that point on Raku kind of expects you to know what Str:U means and
that the :U part means "undefined". It would give the same *type* of
message if you were trying to call a method that only works on undefined
strings and you were trying to call it on a defined string, only then it
would say that it can't find such a method for Str:D. In the eyes of
Raku, these errors are of the same kind, and it has provided you with
the types.

G'luck,
Peter




Hi Peter,

No doubt it is operating as designed.

It would be a lot more friendly if "Str:U" was
changed to "Str:D". Oh please!   Oh Please!

Then the error message would be a lot more useful.

-T


I need help with Config:INI

2020-05-29 Thread ToddAndMargo via perl6-users

Hi All,

I an not figure out how to read the hash.


~~~ ini.test.pl6.ini ~
# Raku: Confug::INI 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
~~~ /ini.test.pl6.ini ~


~~~ ini.test.pl6 ~
#! /usr/bin/env raku

#`{
# zef install Config
# zef install Config::INI



https://github.com/tadzik/perl6-Config-INI/blob/master/lib/Config/INI.pm
line 45 starts documtation

use Config::INI;
my %hash = Config::INI::parse_file('config.ini');
#or
%hash = Config::INI::parse($file_contents);
say %hash<_>;
say %hash;

This module provides 2 functions: parse() and parse_file(), both taking
one C argument, where parse_file is just parse(slurp $file).
Both return a hash which keys are either toplevel keys or a section
names. For example, the following config file:

foo=bar
[section]
another=thing

would result in the following hash:
}
#   { '_' => { foo => "bar" }, section => { another => "thing" } }


use Config;
use Config::INI;

my Str $IniFile = slurp "ini.test.pl6.ini";
my %hash = Config::INI::parse($IniFile);

dd %hash;
print "\n";

for %hash.kv -> $key, $value  { print "   hash<$key> = [$value]\n\n"; }
print "\n";
~~~ /ini.test.pl6 ~

~ run the test 
$ ini.test.pl6

Hash %hash = {"Backup paramters" => ${:partition("BACKUP"), 
:target("B:\\myDocsBackp\\backup1")}, 
:eMail(${:address("bozo\@theclown.com"), :port("587"), 
:smtp("smtp.bozo.com")})}


   hash = [partitionBACKUP
target  B:\myDocsBackp\backup1]

   hash = [address b...@theclown.com
port587
smtpsmtp.bozo.com]
~ /run the test 


How do I read the hash so I get section
`[eMail]` `smtp`?  (Or any of the other values
as well.)


Many thanks,
-T


Re: I reproduced one of the errors!

2020-05-30 Thread ToddAndMargo via perl6-users

On 2020-05-30 04:19, Peter Pentchev wrote:

On Fri, May 29, 2020 at 04:36:41PM -0700, ToddAndMargo via perl6-users wrote:



Hi Peter,

No doubt it is operating as designed.

It would be a lot more friendly if "Str:U" was
changed to "Str:D". Oh please!   Oh Please!


Sorry, I don't really understand what you mean.  "Str:U" means
an undefined string - that's what you're calling .starts-with() on.
"Str:D" means a defined string - that's what .starts-with() wants to
operate on.  What do you mean "change Str:U to Str:D" - the error
message says "you invoked it on an undefined string, it wants to be
invoked on a defined string", what do you want to change?

Now, if you meant "change Str:U to 'an undefined string'", , what
I was trying to explain is that the error message is generic, it covers
any wrong calls of functions on any types... it does not really try to
get into what the types are (it cannot, in the general case for any
other type).

G'luck,
Peter




Hi Peter,

What a second.

https://docs.raku.org/routine/starts-with
multi method starts-with(Str:D: Str(Cool) $needle, :i(:$ignorecase), 
:m(:$ignoremark) --> Bool:D)


https://docs.raku.org/routine/contains
method contains(Cool:D: |c)

I had incorrectly presumed that since neither of
these two complained about `Str:D` not being defined
that it was specified as `Str:U`

So my beef is when you feed these guys an undefined
variable, that they needs to tell you it requires
a "defined" variable.  Not a bunch of useless rubbish.
For example (useless rubbish):

   Cannot resolve caller starts-with(Str:U: Str:D);
   none of these signatures match

   (Cool:D: Cool:D $needle, :i(:$ignorecase)!,
   :m(:$ignoremark), *%_ --> Bool)
   (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_
   --> Bool)
   (Cool:D: Cool:D $needle, *%_ --> Bool)
   (Str:D: Str:D $needle, :i(:$ignorecase)!,
   :m(:$ignoremark), *%_ --> Bool)
   (Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
   (Str:D: Str:D $needle, *%_ --> Bool)
   in block  ...

And I know, I don't get a vote on the matter.
-T


question on pod comments

2020-05-30 Thread ToddAndMargo via perl6-users

Hi All,

I am somewhat confused about pod comments:

https://docs.raku.org/language/syntax#Pod_comments

Seems pretty straight forward.  But when I look at

https://github.com/tadzik/perl6-Config-INI/blob/master/lib/Config/INI.pm

starting line 45, I see

=begin pod
=head1 NAME
=head1 SYNOPSIS
=head1 DESCRIPTION
=end pod

I see no "=end xxx"

=end head1 NAME
=end head1 SYNOPSIS
=end head1 DESCRIPTION

What am I missing?

Many thanks,
-T


Re: I need help with Config:INI

2020-05-30 Thread ToddAndMargo via perl6-users

Follow up.

Special thanks to Peter and David!

I wrote a sample program to explain things in
my personal documentation:

-T


Raku: reading INI files:


Example:

~ini.test.pl6.ini ~~~
# Raku: Config::INI test INI
# edit at your own risk

IHave=NoSection

[Backup paramters]
target=B:\myDocsBackp\backup1
partition=BACKUP

[eMail]
smtp=smtp.bozo.com
address=b...@theclown.com
port=587
~/ini.test.pl6.ini ~~


~~~ini.test.pl6 ~
#! /usr/bin/env raku

=begin introduction

# zef install Config
# zef install Config::INI



https://github.com/tadzik/perl6-Config-INI/blob/master/lib/Config/INI.pm
line 45 starts documtation

use Config::INI;
my %IniHash = Config::INI::parse_file('config.ini');

# Config::INI::parse return a hash of a hash
%IniHash = Config::INI::parse($file_contents);

# items before a [section] tag are given a [section] key value of '_'
print %hash<_> ~ "\n";

# Otherwise the key is the [section] tag
print  %hash ~ "\n";

   IHave=NoSection
   [eMail]
   address=b...@theclown.com

print "[_] IHave = " ~ %IniHash<_> ~ "\n";
print "[eMail] Address = " ~ %IniHash ~ "\n";

[_] IHave = NoSection
[eMail] Address = b...@theclown.com

=end introduction


use Config;
use Config::INI;

my Str $IniFile = slurp "ini.test.pl6.ini";
my %IniHash = Config::INI::parse($IniFile);  # %IniHash is a hash of a hash

print "The following INI file was read:\n";
for $IniFile.lines -> $Line { print "$Line\n"; }
print "\n";

print "The following sections where located:\n";
for %IniHash.kv -> $key, $value  { print "[" ~ $key ~ "]\n"; }
print "\n";

print "The following is a list of INI variables located in each section:\n";
for %IniHash.kv -> $section, $value  {
   print "[" ~ $section ~ "]\n";
   for $value.kv -> $SectionKey, $SectionValue  {
  print "   $SectionKey=$SectionValue\n";
   }
}
print "\n";

print "Direct addressing of values:\n";
print "[_] IHave = " ~ %IniHash<_> ~ "\n";
print "[eMail] Address = " ~ %IniHash ~ "\n";
print "\n";
~~~/ini.test.pl6 


$ ini.test.pl6
The following INI file was read:
# Raku: Config::INI test INI
# edit at your own risk

IHave=NoSection

[Backup paramters]
target=B:\myDocsBackp\backup1
partition=BACKUP

[eMail]
smtp=smtp.bozo.com
address=b...@theclown.com
port=587


The following sections where located:
[_]
[eMail]
[Backup paramters]

The following is a list of INI variables located in each section:
[_]
   IHave=NoSection
[eMail]
   port=587
   address=b...@theclown.com
   smtp=smtp.bozo.com
[Backup paramters]
   target=B:\myDocsBackp\backup1
   partition=BACKUP

Direct addressing of values:
[_] IHave = NoSection
[eMail] Address = b...@theclown.com


Re: I need help with Config:INI

2020-05-30 Thread ToddAndMargo via perl6-users

On 2020-05-30 20:08, ToddAndMargo via perl6-users wrote:

Follow up.


I just opened

An Example to consider adding to your documentation:
https://github.com/tadzik/perl6-Config-INI/issues/17


  1   2   3   4   5   6   7   8   9   10   >