At 4:08 PM +0200 10/10/06, TSa wrote:
HaloO,
Darren Duncan wrote:
Within a system that already has an underlying set-like type, the
Junction in this case, a test for uniqueness is (pardon any
spelling):
all(@items).elements.size === @items.size
The all() will strip any duplicates, so if t
HaloO,
Darren Duncan wrote:
Within a system that already has an underlying set-like type, the
Junction in this case, a test for uniqueness is (pardon any spelling):
all(@items).elements.size === @items.size
The all() will strip any duplicates, so if the number of elements in
all(@items) is
Darren Duncan wrote:
>> Perhaps, but then Junctions might not assume elements have equality or
>> identity operations defined.
>>
> As I recall, every type in Perl 6 has an equality and identity
> operation defined because the Object superclass provides one. If
> nothing else, the type's eq
At 8:13 PM +1200 9/26/06, Sam Vilain wrote:
Darren Duncan wrote:
> Within a system that already has an underlying
set-like type, the Junction in this case, a test
for uniqueness is (pardon any spelling):
all(@items).elements.size === @items.size
The all() will strip any duplicates, so
TSa wrote:
> HaloO,
>
> Sam Vilain wrote:
>
>> perl -MPerl6::Junction=one,all -le '@foo=qw(1 2 3 4); print "yes" if
>> (all(@foo) eq one(@foo))'
>> yes
>>
>
> But does it fail for duplicates? I guess not because junctions
> eliminate duplicates and you end up testing unique values as
> abov
HaloO,
Sam Vilain wrote:
Ah, yes, a notable omission. I understood a Seq as a list with
individual types for each element, which are applied positionally.
I can understand that the type-checker can produce this type
for immutable sequences.
The
superclass for things like Pair.
Hmm, have
Darren Duncan wrote:
> Unless I'm mistaken, you may be going about this the wrong way.
>
> Within a system that already has an underlying
> set-like type, the Junction in this case, a test
> for uniqueness is (pardon any spelling):
>
>all(@items).elements.size === @items.size
>
> The all() wi
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
HaloO,
Sam Vilain wrote:
perl -MPerl6::Junction=one,all -le '@foo=qw(1 2 3 4); print "yes" if
(all(@foo) eq one(@foo))'
yes
But does it fail for duplicates? I guess not because junctions
eliminate duplicates and you end up testing unique values as
above. E.g. all(1,1,2) == one(1,1,2) might act
At 7:28 PM -0700 9/25/06, Ashley Winters wrote:
On 9/25/06, Miroslav Silovic <[EMAIL PROTECTED]> 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 a
On 9/25/06, Miroslav Silovic <[EMAIL PROTECTED]> 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) n
TSa wrote:
>> role Collection[\$types] {
>>has Seq[$types] @.members;
>> }
> This is a little wrapper that ensures that collections have got
> a @.members sequence of arbitrary type. This immediately raises
> the question how Seq is defined.
> [...and later...]
> Are you sure that the u
HaloO,
Miroslav Silovic wrote:
TSa wrote:
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.
Doesn't all(1,2,3) == one(1,2,3) expand the
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 tha
HaloO,
Sam Vilain wrote:
Anyone care to pick holes in this little expression of some Perl 6 core
types as collections? I mean, other than missing methods ;)
My comments follow.
role Collection[\$types] {
has Seq[$types] @.members;
}
This is a little wrapper that ensures that c
Anyone care to pick holes in this little expression of some Perl 6 core
types as collections? I mean, other than missing methods ;)
role Collection[\$types] {
has Seq[$types] @.members;
}
role Set[::T = Item] does Collection[T] where {
all(.members) =:= one(.members);
};
16 matches
Mail list logo