On Wed, Jul 21, 2010 at 3:55 PM, Darren Duncan <dar...@darrenduncan.net> wrote:
> Larry Wall wrote:
>>
>> On Tue, Jul 20, 2010 at 11:53:27PM -0400, Mark J. Reed wrote:
>> : In particular, consider that pi ~~ 0..4 is true,
>> :  because pi is within the range; but pi ~~ 0...4 is false, because pi
>> : is not one of the generated elements.
>>
>> Small point here, it's not because pi is fractional: 3 ~~ 0...4 is
>> also false because 3 !eqv (0,1,2,3,4).  There is no implicit any()
>> on a smartmatch list pattern as there is in Perl 5.  In Perl 6 the
>> pattern 0..4 may only match a list with the same 5 elements in the
>> same order.
>
> For some reason I thought smart match in Perl 6, when presented with some
> collection on the right-hand side, would test if the value on the left-hand
> side was contained in the collection.

That was my thought as well.

> Similarly, since a range represents a set of all values between 2 endpoints,
> I might have thought this would be reasonable:
>
>  3 ~~ 1..5  # TRUE

AIUI, that is indeed correct.  Ranges smartmatch by testing for
inclusion in the range.  But collections don't smartmatch by testing
for inclusion in the collection.  Which was probably the subject of a
thread I missed somewhere...

For series, I think the canonical solution is to use any().

-- 
Mark J. Reed <markjr...@gmail.com>

Reply via email to