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
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")
>
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
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
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 Fals
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
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.
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'
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 ..
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
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.
I
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
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 Rakud
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 fai
14 matches
Mail list logo