I would like to fix collectUnion:
and I would like to understand why
(#((1 2) (3 4) (5 3)) collectUnion: [ :each ]) equalsTo: #(1 2 3 3 4 5))
and not to #(1 2 3 4 5)
is it a bug in the test? Stef
Actually, this was a debate we had before with Hani and Adrian.
The test is correct for what the method is supposed to do.
There are two methods: - collectUnion: should allow several equal elements. This is useful especially in combination with groupedBy: because you can count how many things are there that are the same. - collectAsSet: should not allow several equal elements.
The name of the collectUnion: method is probably confusing because union: returns a unique set of elements. So, maybe we should rename collectAsSet: to collectUnion: and collectUnion: to something like collectConcatenated: (although I do not like this name either).
Cheers, Doru
On Jun 14, 2008, at 3:55 PM, stéphane ducasse wrote:
I would like to fix collectUnion:
and I would like to understand why
(#((1 2) (3 4) (5 3)) collectUnion: [ :each ]) equalsTo: #(1 2 3 3 4 5))
and not to #(1 2 3 4 5)
is it a bug in the test? Stef _______________________________________________ Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com www.tudorgirba.com/blog
"Next time you see your life passing by, say 'hi' and get to know her."
On Jun 15, 2008, at 11:40 AM, Tudor Girba wrote:
Actually, this was a debate we had before with Hani and Adrian.
The test is correct for what the method is supposed to do.
Ok I see. Then I will fix it to make the test green.
There are two methods:
- collectUnion: should allow several equal elements. This is useful
especially in combination with groupedBy: because you can count how many things are there that are the same.
- collectAsSet: should not allow several equal elements.
The name of the collectUnion: method is probably confusing because union: returns a unique set of elements. So, maybe we should rename collectAsSet: to collectUnion: and collectUnion: to something like collectConcatenated: (although I do not like this name either).
collectFlat:? or collectConcatenated:
I prefer to have obvious ugly name than beuatiful misleading one. So I will propose something and we will move everything.
Stef
Cheers, Doru
On Jun 14, 2008, at 3:55 PM, stéphane ducasse wrote:
I would like to fix collectUnion:
and I would like to understand why
(#((1 2) (3 4) (5 3)) collectUnion: [ :each ]) equalsTo: #(1 2 3 3 4 5))
and not to #(1 2 3 4 5)
is it a bug in the test? Stef _______________________________________________ Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com www.tudorgirba.com/blog
"Next time you see your life passing by, say 'hi' and get to know her."
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
As I designed it, collectUnion uses the semantics of the receiver for doing the union, ie the union of arrays can have duplicates. Why? I feel this is more natural (and it performs better for millions of objects, never forget, a set is always implemented as dictionary or worse). This test asserts that no one changes collectUnion to use set semantics for arrays.
But feel free to change this if you prefer set semantics.
AA
On 14 Jun 2008, at 15:55 , stéphane ducasse wrote:
I would like to fix collectUnion:
and I would like to understand why
(#((1 2) (3 4) (5 3)) collectUnion: [ :each ]) equalsTo: #(1 2 3 3 4 5))
and not to #(1 2 3 4 5)
is it a bug in the test? Stef
We will keep it but under flatCollect:
and introduce collectAsSet: for the flatCollect: asSet semantics
Stef
On Jun 17, 2008, at 1:52 AM, Adrian Kuhn wrote:
As I designed it, collectUnion uses the semantics of the receiver for doing the union, ie the union of arrays can have duplicates. Why? I feel this is more natural (and it performs better for millions of objects, never forget, a set is always implemented as dictionary or worse). This test asserts that no one changes collectUnion to use set semantics for arrays.
But feel free to change this if you prefer set semantics.
AA
On 14 Jun 2008, at 15:55 , stéphane ducasse wrote:
I would like to fix collectUnion:
and I would like to understand why
(#((1 2) (3 4) (5 3)) collectUnion: [ :each ]) equalsTo: #(1 2 3 3 4 5))
and not to #(1 2 3 4 5)
is it a bug in the test? Stef
Pay attention, collectAsSet is already there and implemented as
collectAsSet: aBlock (self collect: aBlock) asSet
whereas a hypothetical collectUnionAsSet would do
collectUnionAsSet: aBlock self inject: Set new into: [ :set :each | set addAll: (aBlock value: each) ]
which is not the same.
cheers, AA
On 17 Jun 2008, at 8:47 , stéphane ducasse wrote:
We will keep it but under flatCollect:
and introduce collectAsSet: for the flatCollect: asSet semantics
Stef
On Jun 17, 2008, at 1:52 AM, Adrian Kuhn wrote:
As I designed it, collectUnion uses the semantics of the receiver for doing the union, ie the union of arrays can have duplicates. Why? I feel this is more natural (and it performs better for millions of objects, never forget, a set is always implemented as dictionary or worse). This test asserts that no one changes collectUnion to use set semantics for arrays.
But feel free to change this if you prefer set semantics.
AA
On 14 Jun 2008, at 15:55 , stéphane ducasse wrote:
I would like to fix collectUnion:
and I would like to understand why
(#((1 2) (3 4) (5 3)) collectUnion: [ :each ]) equalsTo: #(1 2 3 3 4 5))
and not to #(1 2 3 4 5)
is it a bug in the test? Stef
thanks I was thinking more about collectUnionAsSet: as an implementation
Sted
On Jun 18, 2008, at 1:11 AM, Adrian Kuhn wrote:
Pay attention, collectAsSet is already there and implemented as
collectAsSet: aBlock (self collect: aBlock) asSet
whereas a hypothetical collectUnionAsSet would do
collectUnionAsSet: aBlock self inject: Set new into: [ :set :each | set addAll: (aBlock value: each) ]
which is not the same.
cheers, AA
On 17 Jun 2008, at 8:47 , stéphane ducasse wrote:
We will keep it but under flatCollect:
and introduce collectAsSet: for the flatCollect: asSet semantics
Stef
On Jun 17, 2008, at 1:52 AM, Adrian Kuhn wrote:
As I designed it, collectUnion uses the semantics of the receiver for doing the union, ie the union of arrays can have duplicates. Why? I feel this is more natural (and it performs better for millions of objects, never forget, a set is always implemented as dictionary or worse). This test asserts that no one changes collectUnion to use set semantics for arrays.
But feel free to change this if you prefer set semantics.
AA
On 14 Jun 2008, at 15:55 , stéphane ducasse wrote:
I would like to fix collectUnion:
and I would like to understand why
(#((1 2) (3 4) (5 3)) collectUnion: [ :each ]) equalsTo: #(1 2 3 3 4 5))
and not to #(1 2 3 4 5)
is it a bug in the test? Stef