Miroslav Silovic wrote:
> TSa wrote:
>
>>> role Set[::T = Item] does Collection[T] where {
>>> all(.members) =:= one(.members);
>>> };
>>>
>> Nice usage of junctions!
>>
>>
>
> But buggy - one means *exactly* one. So for an array of more than 1
> element, all(@array) never equals one(@array) - if they're all the same,
> it's more than 1, otherwise it's 0.
>
>
perl -MPerl6::Junction=one,all -le '@foo=qw(1 2 3 4); print "yes" if
(all(@foo) eq one(@foo))'
yes
Didn't test on pugs yet.
Sam.
> all(.members) =:= any(.members) would also not work, as it will try to
> match each member with some other or same member of the array. It will
> always return true, in other words, as each element of the array is
> equal to itself.
>
> This leaves all(.members) =:= .members[0], possibly extra with
> non-emptiness test.
>
> Miro
>
>
>