Re: subset problem

2016-09-30 Thread mimosinnet

El Saturday, 17 de September del 2016 a les 10:21, MT va escriure:


Btw the following has the same problem;

> my Hash $h = {a=>1,b=>2}
{a => 1, b => 2}
> $h:exists
True
> subset mh of Str where $h{$_}:exists
(mh)
> my mh $x = 'b'
Type check failed in assignment to $x; expected mh but got Str ("b")
  in block  at  line 1



And:

my Hash $h = {a=>1,b=>2};

{a => 1, b => 2}

subset mh of Str where $h{$_}:exists;my mh $x = 'b'

b

:O ;-)

Cheers!


I can’t help but think this can all be solved by using enums?

my enum pv (  );
my pv $x = aa;


??


On 16 Sep 2016, at 13:49, mt1957  wrote:

Hi everyone,

I am trying to create a subset but get errors when used. Surely I do something 
wrong here or is it a bug?

In REPL


my Map $p .= new(.kv.reverse);

Map.new((:aa(4),:bb(5),:d(0),:f(1),:ff(6),:g(2),:h(3)))

subset pv of Str where $_ (elem) $p;

(pv)

my pv $x = 'aa';

Type check failed in assignment to $x; expected pv but got Str ("aa")
  in block  at  line 3


Greetings,

Marce





--
(≧∇≦) Mimosinnet (Linux User: #463211)

(≧∇≦) Ningún Lugar

★ Activisme Cultural per a la Transformació Social

(≧∇≦) Fractalitats en Investigació Crítica

* Investigació Crítica per a la Transformació Social
* http://psicologiasocial.uab.es/fic



Re: subset problem

2016-09-17 Thread yary
On Sat, Sep 17, 2016 at 4:21 AM, MT  wrote:

> Btw the following has the same problem;
>
> > my Hash $h = {a=>1,b=>2}
> {a => 1, b => 2}
> > $h:exists
> True
> > subset mh of Str where $h{$_}:exists
> (mh)
> > my mh $x = 'b'
> Type check failed in assignment to $x; expected mh but got Str ("b")
>   in block  at  line 1
>

That's a REPL bug, the all on one line it works.

> my Hash $h = {a=>1,b=>2};subset mh of Str where $h{$_}:exists;my mh $x =
'b'
b

That's worth opening a bug about.


> should I open a ticket for the Map/subset thing?

I'm not so sure now. With "exists" instead of "(elem)" there's no such
problem, and after reading Elizabeth's explanation "(elem)"'s behavior
makes more sense.

-y


Re: subset problem

2016-09-17 Thread MT

Hi,
thanks for all your ideas,

I have used the enum before but turned to Map for some reason, don't 
know why (getting old I think (hopefully)).


But still, should I open a ticket for the Map/subset thing?

Btw the following has the same problem;

> my Hash $h = {a=>1,b=>2}
{a => 1, b => 2}
> $h:exists
True
> subset mh of Str where $h{$_}:exists
(mh)
> my mh $x = 'b'
Type check failed in assignment to $x; expected mh but got Str ("b")
  in block  at  line 1

Greetings,
Marcel


I can’t help but think this can all be solved by using enums?

my enum pv (  );
my pv $x = aa;


??


On 16 Sep 2016, at 13:49, mt1957  wrote:

Hi everyone,

I am trying to create a subset but get errors when used. Surely I do something 
wrong here or is it a bug?

In REPL


my Map $p .= new(.kv.reverse);

Map.new((:aa(4),:bb(5),:d(0),:f(1),:ff(6),:g(2),:h(3)))

subset pv of Str where $_ (elem) $p;

(pv)

my pv $x = 'aa';

Type check failed in assignment to $x; expected pv but got Str ("aa")
  in block  at  line 3


Greetings,

Marce





Re: subset problem

2016-09-16 Thread Elizabeth Mattijsen
I can’t help but think this can all be solved by using enums?

my enum pv (  );
my pv $x = aa;


??

> On 16 Sep 2016, at 13:49, mt1957  wrote:
> 
> Hi everyone,
> 
> I am trying to create a subset but get errors when used. Surely I do 
> something wrong here or is it a bug?
> 
> In REPL
> 
> > my Map $p .= new(.kv.reverse);
> Map.new((:aa(4),:bb(5),:d(0),:f(1),:ff(6),:g(2),:h(3)))
> > subset pv of Str where $_ (elem) $p;
> (pv)
> > my pv $x = 'aa';
> Type check failed in assignment to $x; expected pv but got Str ("aa")
>  in block  at  line 3
> 
> 
> Greetings,
> 
> Marce
> 



Re: subset problem

2016-09-16 Thread Elizabeth Mattijsen
That’s because (elem) will coerce its righthand side parameter to a Bag.  If 
the count in a Bag goes to 0, the element doesn’t exist, and therefore returns 
False.

> On 16 Sep 2016, at 23:17, Brandon Allbery  wrote:
> 
> 
> On Fri, Sep 16, 2016 at 5:04 PM, yary  wrote:
> Having (elem) return False when the value of a Map element is 0 confuses me.
> 
> Me too, I disliked it the moment you pointed it out. I think that behavior is 
> intended for Bags, I am not sure it has any business being in Sets.
> 
> 
> -- 
> brandon s allbery kf8nh   sine nomine associates
> allber...@gmail.com  ballb...@sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net



Re: subset problem

2016-09-16 Thread Brandon Allbery
On Fri, Sep 16, 2016 at 5:04 PM, yary  wrote:

> Having (elem) return False when the value of a Map element is 0 confuses
> me.


Me too, I disliked it the moment you pointed it out. I think that behavior
is intended for Bags, I am not sure it has any business being in Sets.


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


Re: subset problem

2016-09-16 Thread yary
After reading the docs more,

"Set" is better than "Bag" for this, since "Bag" has a count whereas "Set"
is purely for membership.

Having (elem) return False when the value of a Map element is 0 confuses me.


Re: subset problem

2016-09-16 Thread yary
You're using a "Map" when you want to use a "Bag" I think... when the Map
has a count of 0, (elem) returns False.

my Map $p .= new(.kv.reverse); # Map.new((:d(0),:f(1),:g(2)))
say 'f' (elem) $p; # True
say 'd' (elem) $p; # False
my Bag $b .= new(); # bag(g, f, d)
say 'd' (elem) $b; # True
say 'f' (elem) $b; # True
say 'g' (elem) $b; # True


Re: subset problem

2016-09-16 Thread mt1957

The files are PRECIS.pm6 and 100-precis.t in the attachment
The Map definitions is at 13 and subset on line 20 of file PRECIS.pm6. 
Use is at method exceptions at line 172 in the same file.

The error is generated on line 85 in 100-precis.t

> prove -e perl6 -v t/100-precis.t
t/100-precis.t ..
ok 1 - À (0xc0) in Lu set
ok 2 - é (0xe9) in Ll set
ok 3 - 0x0064 in Ascii7 set
ok 4 -
1..4
ok 1 - Test tables
ok 1 - exceptions check for PVALID
ok 2 - properties check for PVALID
ok 3 - exceptions check for CONTEXTO
ok 4 - properties check for CONTEXTO
1..4
ok 2 - Test exceptions
ok 1 - 0x0005dd in letter-digits set
ok 2 - 0x0005c6 not in letter-digits set
ok 3 - 0x000660 is a CONTEXTO exception
Type check failed for return value; expected Unicode::PRECIS::PropValue 
but got Str ("PVALID")
  in method exceptions at 
/home/marcel/Languages/Perl6/Projects/unicode-precis/lib/Unicode/PRECIS.pm6 
(Unicode::PRECIS) line 175

  in block  at t/100-precis.t line 85

Dubious, test returned 1 (wstat 256, 0x100)
All 2 subtests passed

Test Summary Report
---
t/100-precis.t (Wstat: 256 Tests: 2 Failed: 0)
  Non-zero exit status: 1
  Parse errors: No plan found in TAP output
Files=1, Tests=2,  1 wallclock secs ( 0.03 usr  0.00 sys +  1.08 cusr  
0.09 csys =  1.20 CPU)

Result: FAIL





PRECIS.pm6
Description: application/pagemaker


100-precis.t
Description: Perl program


Re: subset problem

2016-09-16 Thread Fernando Santagata
Here I see this:

$ perl6 --version
This is Rakudo version 2016.08.1 built on MoarVM version 2016.08
implementing Perl 6.c.
$ perl6
To exit type 'exit' or '^D'
> my Map $p .= new(.kv.reverse);subset pv of Str where $_
(elem) $p;my pv $x = 'aa';say $x;
aa

But if I feed three separate statements to the REPL, I receive the same
error you have, so I think there's indeed a bug somewhere.

On Fri, Sep 16, 2016 at 3:48 PM, mt1957  wrote:

> Hi Fernando,
>
> I had this problem from a module I am writing and there it went wrong with
> this error. So, not only REPL has problems. Perhaps I should write a bug
> ticket.
>
> Marcel,
>
> P.s. Rakudo version 2016.08.1-117-g1d8f99a built on MoarVM version
> 2016.08-32-ge52414d
> implementing Perl 6.c.
>
>
> It works fine if the three statements are on the same line and if the
> program is being read from a file, so I guess it's bug of the REPL.
>
> On Fri, Sep 16, 2016 at 1:49 PM, mt1957  wrote:
>
>> Hi everyone,
>>
>> I am trying to create a subset but get errors when used. Surely I do
>> something wrong here or is it a bug?
>>
>> In REPL
>>
>> > my Map $p .= new(.kv.reverse);
>> Map.new((:aa(4),:bb(5),:d(0),:f(1),:ff(6),:g(2),:h(3)))
>> > subset pv of Str where $_ (elem) $p;
>> (pv)
>> > my pv $x = 'aa';
>> Type check failed in assignment to $x; expected pv but got Str ("aa")
>>   in block  at  line 3
>>
>>
>> Greetings,
>>
>> Marce
>>
>>
>
>
> --
> Fernando Santagata
>
>
>


-- 
Fernando Santagata


Re: subset problem

2016-09-16 Thread mt1957

Hi Fernando,

I had this problem from a module I am writing and there it went wrong 
with this error. So, not only REPL has problems. Perhaps I should write 
a bug ticket.


Marcel,

P.s. Rakudo version 2016.08.1-117-g1d8f99a built on MoarVM version 
2016.08-32-ge52414d

implementing Perl 6.c.


It works fine if the three statements are on the same line and if the 
program is being read from a file, so I guess it's bug of the REPL.


On Fri, Sep 16, 2016 at 1:49 PM, mt1957 > wrote:


Hi everyone,

I am trying to create a subset but get errors when used. Surely I
do something wrong here or is it a bug?

In REPL

> my Map $p .= new(.kv.reverse);
Map.new((:aa(4),:bb(5),:d(0),:f(1),:ff(6),:g(2),:h(3)))
> subset pv of Str where $_ (elem) $p;
(pv)
> my pv $x = 'aa';
Type check failed in assignment to $x; expected pv but got Str ("aa")
  in block  at  line 3


Greetings,

Marce




--
Fernando Santagata





Re: subset problem

2016-09-16 Thread Fernando Santagata
It works fine if the three statements are on the same line and if the
program is being read from a file, so I guess it's bug of the REPL.

On Fri, Sep 16, 2016 at 1:49 PM, mt1957  wrote:

> Hi everyone,
>
> I am trying to create a subset but get errors when used. Surely I do
> something wrong here or is it a bug?
>
> In REPL
>
> > my Map $p .= new(.kv.reverse);
> Map.new((:aa(4),:bb(5),:d(0),:f(1),:ff(6),:g(2),:h(3)))
> > subset pv of Str where $_ (elem) $p;
> (pv)
> > my pv $x = 'aa';
> Type check failed in assignment to $x; expected pv but got Str ("aa")
>   in block  at  line 3
>
>
> Greetings,
>
> Marce
>
>


-- 
Fernando Santagata


Re: subset problem

2016-09-16 Thread yary
It seems the variable as seen my the subset declaration is undefined.
Here's a simplified example:

> my $must_be='b'
b
> subset OneStr of Str where $_ eq $must_be;
(OneStr)
> my OneStr $x = 'b'
Use of uninitialized value $must_be of type Any in string context

I don't know if that's a bug in Rakudo, or if it makes sense in some bigger
picture.