Re: Set difference using hashes vs array

2017-11-23 Thread ToddAndMargo

On 11/23/2017 06:09 PM, Brandon Allbery wrote:
On Thu, Nov 23, 2017 at 9:06 PM, ToddAndMargo > wrote:


On 11/22/2017 08:41 PM, Norman Gaywood wrote:

my Set $take1 = (%all (-) %remove) (-) %excludes;


What does "Set" do in the above?


Declares a type, which helps avoid errors. Similarly `my Int $a` means 
$a can only take Int values.


That explains it.  Pre-declared.  Thank you!


Re: Set difference using hashes vs array

2017-11-23 Thread Brandon Allbery
On Thu, Nov 23, 2017 at 9:06 PM, ToddAndMargo  wrote:

> On 11/22/2017 08:41 PM, Norman Gaywood wrote:
>
>> my Set $take1 = (%all (-) %remove) (-) %excludes;
>>
>
> What does "Set" do in the above?
>

Declares a type, which helps avoid errors. Similarly `my Int $a` means $a
can only take Int values.

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: Set difference using hashes vs array

2017-11-23 Thread ToddAndMargo

On 11/22/2017 08:41 PM, Norman Gaywood wrote:

my Set $take1 = (%all (-) %remove) (-) %excludes;


What does "Set" do in the above?


Re: Set difference using hashes vs array

2017-11-23 Thread Elizabeth Mattijsen
Fixed with https://github.com/rakudo/rakudo/commit/eacf9b2776 .  Thanks for 
reporting!


> On 23 Nov 2017, at 05:27, Norman Gaywood  wrote:
> 
> Talking to myself :-) 
> 
> Seems it has something to do with the values in the hash. If they are just 
> True, this works:
> $ perl6
> To exit type 'exit' or '^D'
> > my %a= :k, :e, :r; my %r= :r; my %e= :e; my Set $s = %a (-) %r (-) %e;
> set(k)
> 
> 
> 
> On 23 November 2017 at 16:20, Norman Gaywood  wrote:
> For compactness, here are the 1-liners:
> 
> $ perl6
> To exit type 'exit' or '^D'
> > my %a= k=>"k", e=>"e", r=>"r"; my %r= r=>"r"; my %e= e=>"e"; my Set $s = %a 
> > (-) %r (-) %e;
> Cannot convert string to number: base-10 number must begin with valid digits 
> or '.' in '⏏k' (indicated by ⏏)
>   in block  at  line 1
> 
> > my %a= k=>"k", e=>"e", r=>"r"; my %r= r=>"r"; my %e= e=>"e"; my Set $s = 
> > (%a (-) %r) (-) %e;
> set(k)
> > my @a= "k", "e", "r"; my @r= "r"; my @e= "e"; my Set $s = @a (-) @r (-) @e;
> set(k)
> > 
> 
> 
> On 23 November 2017 at 15:41, Norman Gaywood  wrote:
> I'm not sure what this error message means and what is going on here:
> perl6 --version
> This is Rakudo version 2017.08 built on MoarVM version 2017.08.1
> implementing Perl 6.c.
> 
> $ cat tt-h.p6 
> #!/usr/bin/env perl6
> 
> my %excludes = "exclude" => "exclude";
> my %all = :keep("keep"), :exclude("exclude"), :remove("remove");
> my %remove = :remove("remove");
> 
> my Set $take1 = (%all (-) %remove) (-) %excludes;
> dd $take1;
> my Set $take2 = %all (-) %remove (-) %excludes;
> dd $take2;
> 
> $ ./tt-h.p6 
> Set $take1 = set("keep")
> Cannot convert string to number: base-10 number must begin with valid digits 
> or '.' in '⏏remove' (indicated by ⏏)
>   in block  at ./tt-h.p6 line 10
> 
> The difference in $take1 and $take2 are the brackets around the 1st set 
> operation.
> 
> If I use arrays then no problem with either expression:
> 
> $ cat tt-a.p6 
> #!/usr/bin/env perl6
> 
> my @excludes = "exclude";
> my @all = "keep", "exclude", "remove";
> my @remove = "remove";
> 
> my Set $take1 = (@all (-) @remove) (-) @excludes;
> dd $take1;
> my Set $take2 = @all (-) @remove (-) @excludes;
> dd $take2;
> 
> $ ./tt-a.p6 
> Set $take1 = set("keep")
> Set $take2 = set("keep")
> 
> -- 
> Norman Gaywood, Computer Systems Officer
> School of Science and Technology
> University of New England
> Armidale NSW 2351, Australia
> 
> ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
> Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062
> 
> Please avoid sending me Word or Power Point attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html
> 
> 
> 
> -- 
> Norman Gaywood, Computer Systems Officer
> School of Science and Technology
> University of New England
> Armidale NSW 2351, Australia
> 
> ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
> Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062
> 
> Please avoid sending me Word or Power Point attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html
> 
> 
> 
> -- 
> Norman Gaywood, Computer Systems Officer
> School of Science and Technology
> University of New England
> Armidale NSW 2351, Australia
> 
> ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
> Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062
> 
> Please avoid sending me Word or Power Point attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html


Re: Set difference using hashes vs array

2017-11-23 Thread Elizabeth Mattijsen
Will have a look at this in about 12 hours (probably).  Meanwhile, don’t let 
that stop anyone from figuring this out  :-)


> On 23 Nov 2017, at 05:27, Norman Gaywood  wrote:
> 
> Talking to myself :-) 
> 
> Seems it has something to do with the values in the hash. If they are just 
> True, this works:
> $ perl6
> To exit type 'exit' or '^D'
> > my %a= :k, :e, :r; my %r= :r; my %e= :e; my Set $s = %a (-) %r (-) %e;
> set(k)
> 
> 
> 
> On 23 November 2017 at 16:20, Norman Gaywood  wrote:
> For compactness, here are the 1-liners:
> 
> $ perl6
> To exit type 'exit' or '^D'
> > my %a= k=>"k", e=>"e", r=>"r"; my %r= r=>"r"; my %e= e=>"e"; my Set $s = %a 
> > (-) %r (-) %e;
> Cannot convert string to number: base-10 number must begin with valid digits 
> or '.' in '⏏k' (indicated by ⏏)
>   in block  at  line 1
> 
> > my %a= k=>"k", e=>"e", r=>"r"; my %r= r=>"r"; my %e= e=>"e"; my Set $s = 
> > (%a (-) %r) (-) %e;
> set(k)
> > my @a= "k", "e", "r"; my @r= "r"; my @e= "e"; my Set $s = @a (-) @r (-) @e;
> set(k)
> > 
> 
> 
> On 23 November 2017 at 15:41, Norman Gaywood  wrote:
> I'm not sure what this error message means and what is going on here:
> perl6 --version
> This is Rakudo version 2017.08 built on MoarVM version 2017.08.1
> implementing Perl 6.c.
> 
> $ cat tt-h.p6 
> #!/usr/bin/env perl6
> 
> my %excludes = "exclude" => "exclude";
> my %all = :keep("keep"), :exclude("exclude"), :remove("remove");
> my %remove = :remove("remove");
> 
> my Set $take1 = (%all (-) %remove) (-) %excludes;
> dd $take1;
> my Set $take2 = %all (-) %remove (-) %excludes;
> dd $take2;
> 
> $ ./tt-h.p6 
> Set $take1 = set("keep")
> Cannot convert string to number: base-10 number must begin with valid digits 
> or '.' in '⏏remove' (indicated by ⏏)
>   in block  at ./tt-h.p6 line 10
> 
> The difference in $take1 and $take2 are the brackets around the 1st set 
> operation.
> 
> If I use arrays then no problem with either expression:
> 
> $ cat tt-a.p6 
> #!/usr/bin/env perl6
> 
> my @excludes = "exclude";
> my @all = "keep", "exclude", "remove";
> my @remove = "remove";
> 
> my Set $take1 = (@all (-) @remove) (-) @excludes;
> dd $take1;
> my Set $take2 = @all (-) @remove (-) @excludes;
> dd $take2;
> 
> $ ./tt-a.p6 
> Set $take1 = set("keep")
> Set $take2 = set("keep")
> 
> -- 
> Norman Gaywood, Computer Systems Officer
> School of Science and Technology
> University of New England
> Armidale NSW 2351, Australia
> 
> ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
> Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062
> 
> Please avoid sending me Word or Power Point attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html
> 
> 
> 
> -- 
> Norman Gaywood, Computer Systems Officer
> School of Science and Technology
> University of New England
> Armidale NSW 2351, Australia
> 
> ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
> Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062
> 
> Please avoid sending me Word or Power Point attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html
> 
> 
> 
> -- 
> Norman Gaywood, Computer Systems Officer
> School of Science and Technology
> University of New England
> Armidale NSW 2351, Australia
> 
> ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
> Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062
> 
> Please avoid sending me Word or Power Point attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html


Re: Set difference using hashes vs array

2017-11-22 Thread Norman Gaywood
Talking to myself :-)

Seems it has something to do with the values in the hash. If they are just
True, this works:
$ perl6
To exit type 'exit' or '^D'
> my %a= :k, :e, :r; my %r= :r; my %e= :e; my Set $s = %a (-) %r (-) %e;
set(k)



On 23 November 2017 at 16:20, Norman Gaywood  wrote:

> For compactness, here are the 1-liners:
>
> $ perl6
> To exit type 'exit' or '^D'
> > my %a= k=>"k", e=>"e", r=>"r"; my %r= r=>"r"; my %e= e=>"e"; my Set $s =
> %a (-) %r (-) %e;
> Cannot convert string to number: base-10 number must begin with valid
> digits or '.' in '⏏k' (indicated by ⏏)
>   in block  at  line 1
>
> > my %a= k=>"k", e=>"e", r=>"r"; my %r= r=>"r"; my %e= e=>"e"; my Set $s =
> (%a (-) %r) (-) %e;
> set(k)
> > my @a= "k", "e", "r"; my @r= "r"; my @e= "e"; my Set $s = @a (-) @r (-)
> @e;
> set(k)
> >
>
>
> On 23 November 2017 at 15:41, Norman Gaywood  wrote:
>
>> I'm not sure what this error message means and what is going on here:
>> perl6 --version
>> This is Rakudo version 2017.08 built on MoarVM version 2017.08.1
>> implementing Perl 6.c.
>>
>> $ cat tt-h.p6
>> #!/usr/bin/env perl6
>>
>> my %excludes = "exclude" => "exclude";
>> my %all = :keep("keep"), :exclude("exclude"), :remove("remove");
>> my %remove = :remove("remove");
>>
>> my Set $take1 = (%all (-) %remove) (-) %excludes;
>> dd $take1;
>> my Set $take2 = %all (-) %remove (-) %excludes;
>> dd $take2;
>>
>> $ ./tt-h.p6
>> Set $take1 = set("keep")
>> Cannot convert string to number: base-10 number must begin with valid
>> digits or '.' in '⏏remove' (indicated by ⏏)
>>   in block  at ./tt-h.p6 line 10
>>
>> The difference in $take1 and $take2 are the brackets around the 1st set
>> operation.
>>
>> If I use arrays then no problem with either expression:
>>
>> $ cat tt-a.p6
>> #!/usr/bin/env perl6
>>
>> my @excludes = "exclude";
>> my @all = "keep", "exclude", "remove";
>> my @remove = "remove";
>>
>> my Set $take1 = (@all (-) @remove) (-) @excludes;
>> dd $take1;
>> my Set $take2 = @all (-) @remove (-) @excludes;
>> dd $take2;
>>
>> $ ./tt-a.p6
>> Set $take1 = set("keep")
>> Set $take2 = set("keep")
>>
>> --
>> Norman Gaywood, Computer Systems Officer
>> School of Science and Technology
>> University of New England
>> Armidale NSW 2351, Australia
>>
>> ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
>> Phone: +61 (0)2 6773 2412 <(02)%206773%202412>  Mobile: +61 (0)4 7862
>> 0062
>>
>> Please avoid sending me Word or Power Point attachments.
>> See http://www.gnu.org/philosophy/no-word-attachments.html
>>
>
>
>
> --
> Norman Gaywood, Computer Systems Officer
> School of Science and Technology
> University of New England
> Armidale NSW 2351, Australia
>
> ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
> Phone: +61 (0)2 6773 2412 <(02)%206773%202412>  Mobile: +61 (0)4 7862 0062
>
> Please avoid sending me Word or Power Point attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html
>



-- 
Norman Gaywood, Computer Systems Officer
School of Science and Technology
University of New England
Armidale NSW 2351, Australia

ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062

Please avoid sending me Word or Power Point attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


Re: Set difference using hashes vs array

2017-11-22 Thread Norman Gaywood
For compactness, here are the 1-liners:

$ perl6
To exit type 'exit' or '^D'
> my %a= k=>"k", e=>"e", r=>"r"; my %r= r=>"r"; my %e= e=>"e"; my Set $s =
%a (-) %r (-) %e;
Cannot convert string to number: base-10 number must begin with valid
digits or '.' in '⏏k' (indicated by ⏏)
  in block  at  line 1

> my %a= k=>"k", e=>"e", r=>"r"; my %r= r=>"r"; my %e= e=>"e"; my Set $s =
(%a (-) %r) (-) %e;
set(k)
> my @a= "k", "e", "r"; my @r= "r"; my @e= "e"; my Set $s = @a (-) @r (-)
@e;
set(k)
>


On 23 November 2017 at 15:41, Norman Gaywood  wrote:

> I'm not sure what this error message means and what is going on here:
> perl6 --version
> This is Rakudo version 2017.08 built on MoarVM version 2017.08.1
> implementing Perl 6.c.
>
> $ cat tt-h.p6
> #!/usr/bin/env perl6
>
> my %excludes = "exclude" => "exclude";
> my %all = :keep("keep"), :exclude("exclude"), :remove("remove");
> my %remove = :remove("remove");
>
> my Set $take1 = (%all (-) %remove) (-) %excludes;
> dd $take1;
> my Set $take2 = %all (-) %remove (-) %excludes;
> dd $take2;
>
> $ ./tt-h.p6
> Set $take1 = set("keep")
> Cannot convert string to number: base-10 number must begin with valid
> digits or '.' in '⏏remove' (indicated by ⏏)
>   in block  at ./tt-h.p6 line 10
>
> The difference in $take1 and $take2 are the brackets around the 1st set
> operation.
>
> If I use arrays then no problem with either expression:
>
> $ cat tt-a.p6
> #!/usr/bin/env perl6
>
> my @excludes = "exclude";
> my @all = "keep", "exclude", "remove";
> my @remove = "remove";
>
> my Set $take1 = (@all (-) @remove) (-) @excludes;
> dd $take1;
> my Set $take2 = @all (-) @remove (-) @excludes;
> dd $take2;
>
> $ ./tt-a.p6
> Set $take1 = set("keep")
> Set $take2 = set("keep")
>
> --
> Norman Gaywood, Computer Systems Officer
> School of Science and Technology
> University of New England
> Armidale NSW 2351, Australia
>
> ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
> Phone: +61 (0)2 6773 2412 <(02)%206773%202412>  Mobile: +61 (0)4 7862 0062
>
> Please avoid sending me Word or Power Point attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html
>



-- 
Norman Gaywood, Computer Systems Officer
School of Science and Technology
University of New England
Armidale NSW 2351, Australia

ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062

Please avoid sending me Word or Power Point attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


Set difference using hashes vs array

2017-11-22 Thread Norman Gaywood
I'm not sure what this error message means and what is going on here:
perl6 --version
This is Rakudo version 2017.08 built on MoarVM version 2017.08.1
implementing Perl 6.c.

$ cat tt-h.p6
#!/usr/bin/env perl6

my %excludes = "exclude" => "exclude";
my %all = :keep("keep"), :exclude("exclude"), :remove("remove");
my %remove = :remove("remove");

my Set $take1 = (%all (-) %remove) (-) %excludes;
dd $take1;
my Set $take2 = %all (-) %remove (-) %excludes;
dd $take2;

$ ./tt-h.p6
Set $take1 = set("keep")
Cannot convert string to number: base-10 number must begin with valid
digits or '.' in '⏏remove' (indicated by ⏏)
  in block  at ./tt-h.p6 line 10

The difference in $take1 and $take2 are the brackets around the 1st set
operation.

If I use arrays then no problem with either expression:

$ cat tt-a.p6
#!/usr/bin/env perl6

my @excludes = "exclude";
my @all = "keep", "exclude", "remove";
my @remove = "remove";

my Set $take1 = (@all (-) @remove) (-) @excludes;
dd $take1;
my Set $take2 = @all (-) @remove (-) @excludes;
dd $take2;

$ ./tt-a.p6
Set $take1 = set("keep")
Set $take2 = set("keep")

-- 
Norman Gaywood, Computer Systems Officer
School of Science and Technology
University of New England
Armidale NSW 2351, Australia

ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062

Please avoid sending me Word or Power Point attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html