Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logical problem with "one" junction in Perl6

I am having some trouble with .one junction and range match:

> say (3,5).any ~~ (1 .. 9)
any(True, True)
> say so (3,5).any ~~ (1 .. 9)
True
> say so (3,5).one ~~ (1 .. 9)
False
> say so (3,0).one ~~ (1 .. 9)  # expect True because 0 not in range and 3 is
False
> say so (3,0).any ~~ (1 .. 9)
True
> say so (0, 3).one ~~ (1..9)   # expected True; 0 not in range; exactly one item (3) is in range
False
> so 0 ~~ 1..9                  # as expected;
False
> so 3 ~~ 1..9
True
> say (0, 3).one ~~ (1..9)      # unexpected; 0 not in range;
one(True, True)                 # expected one(False, True)
> say (1..9).elems
9
> say (0, 10).one ~~ (1..9)     # why is it true that 0 ~~ 1..9 ??
one(True, False)
> say so (0, 10).one ~~ (1..9)  # unexpected !!! neither 0 nor 10 in range
True
> say (-1, 3).one ~~ (1..9)     # why -1 in range of 1..9 ??
one(True, True)
> 

What am I missing? I am using Rakudo Star 2018.10 on MoarVM, implementing Perl6.c.

like image 419
lisprogtor Avatar asked Feb 06 '19 21:02

lisprogtor


1 Answers

I think the underlying problem is this:

$ perl6 -e 'dd (0,3).one ~~ (1 .. 9)'
one(Bool::True, Bool::True)

That should be one(Bool::False, Bool::True). I think this is a bug, worthy of making an issue for.

like image 87
Elizabeth Mattijsen Avatar answered Sep 28 '22 04:09

Elizabeth Mattijsen