Re: Nitpick my Perl6 - parametric roles

2006-10-10 Thread Darren Duncan
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

Re: Nitpick my Perl6 - parametric roles

2006-10-10 Thread TSa
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

Re: Nitpick my Perl6 - parametric roles

2006-09-26 Thread Sam Vilain
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

Re: Nitpick my Perl6 - parametric roles

2006-09-26 Thread Darren Duncan
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

Re: Nitpick my Perl6 - parametric roles

2006-09-26 Thread Sam Vilain
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

Re: Nitpick my Perl6 - parametric roles

2006-09-26 Thread TSa
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

Re: Nitpick my Perl6 - parametric roles

2006-09-26 Thread Sam Vilain
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

Re: Nitpick my Perl6 - parametric roles

2006-09-26 Thread Sam Vilain
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

Re: Nitpick my Perl6 - parametric roles

2006-09-26 Thread TSa
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

Re: Nitpick my Perl6 - parametric roles

2006-09-25 Thread Darren Duncan
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

Re: Nitpick my Perl6 - parametric roles

2006-09-25 Thread Ashley Winters
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

Re: Nitpick my Perl6 - parametric roles

2006-09-25 Thread Sam Vilain
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

Re: Nitpick my Perl6 - parametric roles

2006-09-25 Thread TSa
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

Re: Nitpick my Perl6 - parametric roles

2006-09-25 Thread Miroslav Silovic
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

Re: Nitpick my Perl6 - parametric roles

2006-09-25 Thread TSa
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

Nitpick my Perl6 - parametric roles

2006-09-25 Thread Sam Vilain
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); };