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
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
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
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
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
Fixed in https://github.com/rakudo/rakudo/commit/d63f983290
Tests added in https://github.com/perl6/roast/commit/0ade2a58c9
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 ..
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'
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.
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
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
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
# New Ticket Created by Rob Hoelz
# Please include the string: [perl #129290]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=129290 >
For example:
> use v6;
>
> for ^26 { my $p = -> {};
>
>
> ===SORRY!===
> Expression needs
13 matches
Mail list logo