set equality has changed :-(

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

set equality has changed :-(

Eliot Miranda-2
Hi All,

    this used to work:

    (Set with: #module) = (IdentitySet with: #module)

when did this change and why?

_,,,^..^,,,_
best, Eliot


Reply | Threaded
Open this post in threaded view
|

Re: set equality has changed :-(

Chris Muller-3
Déjà vu.  I think we did make this fix last year, IIRC, you were there.

We have #hasEqualElements: on SequenceableCollection, I think we
should have one on Set too.


On Mon, Apr 18, 2016 at 1:50 PM, Eliot Miranda <[hidden email]> wrote:

> Hi All,
>
>     this used to work:
>
>     (Set with: #module) = (IdentitySet with: #module)
>
> when did this change and why?
>
> _,,,^..^,,,_
> best, Eliot
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: set equality has changed :-(

Levente Uzonyi
In reply to this post by Eliot Miranda-2
Hi Eliot,

On Mon, 18 Apr 2016, Eliot Miranda wrote:

> Hi All,
>     this used to work:
>
>     (Set with: #module) = (IdentitySet with: #module)
>
> when did this change and why?

I changed it in Collections-ul.669 last November, because it didn't work
well. Let's see a different example:

| s i |
s := Set with: 'module' copy.
i := IdentitySet with: 'module' copy.
{
  s = i.
  i = s
}

The old implementation would return #(false true), while the new one
evaluates to #(false false).

Levente

>
> _,,,^..^,,,_
> best, Eliot
>
>

Reply | Threaded
Open this post in threaded view
|

Re: set equality has changed :-(

Eliot Miranda-2


On Mon, Apr 18, 2016 at 3:43 PM, Levente Uzonyi <[hidden email]> wrote:
Hi Eliot,

On Mon, 18 Apr 2016, Eliot Miranda wrote:

Hi All,
    this used to work:

    (Set with: #module) = (IdentitySet with: #module)

when did this change and why?

I changed it in Collections-ul.669 last November, because it didn't work well. Let's see a different example:

| s i |
s := Set with: 'module' copy.
i := IdentitySet with: 'module' copy.
{
        s = i.
        i = s
}

The old implementation would return #(false true), while the new one evaluates to #(false false).

Right.  That's a pain, but fair enough.  This is clumsy: (aSet size = 1 and: [aSet anyOne = #module]).  This slightly less so:  aSet = (aSet species with: #module).

Levente

_,,,^..^,,,_
best, Eliot

_,,,^..^,,,_
best, Eliot


Reply | Threaded
Open this post in threaded view
|

Re: set equality has changed :-(

Levente Uzonyi
On Mon, 18 Apr 2016, Eliot Miranda wrote:

>
>
> On Mon, Apr 18, 2016 at 3:43 PM, Levente Uzonyi <[hidden email]> wrote:
>       Hi Eliot,
>
>       On Mon, 18 Apr 2016, Eliot Miranda wrote:
>
>             Hi All,
>                 this used to work:
>
>                 (Set with: #module) = (IdentitySet with: #module)
>
>             when did this change and why?
>
>
>       I changed it in Collections-ul.669 last November, because it didn't work well. Let's see a different example:
>
>       | s i |
>       s := Set with: 'module' copy.
>       i := IdentitySet with: 'module' copy.
>       {
>               s = i.
>               i = s
>       }
>
>       The old implementation would return #(false true), while the new one evaluates to #(false false).
>
>
> Right.  That's a pain, but fair enough.  This is clumsy: (aSet size = 1 and: [aSet anyOne = #module]).  This slightly less so:  aSet = (aSet
> species with: #module).
You could also write it as

aSet asArray = #(module).

or as

(aSet as: Set) = (Set with: #module).


Levente

>
>       Levente
>
>             _,,,^..^,,,_
>             best, Eliot
>
>
> _,,,^..^,,,_
> best, Eliot
>
>

Reply | Threaded
Open this post in threaded view
|

Re: set equality has changed :-(

marcel.taeumel
In reply to this post by Eliot Miranda-2
Hi Eliot,

try this:
(Set with: #module) includesAllOf: (IdentitySet with: #module).

This is "hasEqualElements:" for all kinds of collections.

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: set equality has changed :-(

Tobias Pape

On 19.04.2016, at 08:23, marcel.taeumel <[hidden email]> wrote:

> Hi Eliot,
>
> try this:
> (Set with: #module) includesAllOf: (IdentitySet with: #module).
>
> This is "hasEqualElements:" for all kinds of collections.

But this is not reflexive, right?

(Set withAll: #(module moep)) includesAllOf: (IdentitySet with: #module)



>
> Best,
> Marcel




Reply | Threaded
Open this post in threaded view
|

Re: set equality has changed :-(

Eliot Miranda-2
In reply to this post by Levente Uzonyi


On Mon, Apr 18, 2016 at 5:18 PM, Levente Uzonyi <[hidden email]> wrote:
On Mon, 18 Apr 2016, Eliot Miranda wrote:



On Mon, Apr 18, 2016 at 3:43 PM, Levente Uzonyi <[hidden email]> wrote:
      Hi Eliot,

      On Mon, 18 Apr 2016, Eliot Miranda wrote:

            Hi All,
                this used to work:

                (Set with: #module) = (IdentitySet with: #module)

            when did this change and why?


      I changed it in Collections-ul.669 last November, because it didn't work well. Let's see a different example:

      | s i |
      s := Set with: 'module' copy.
      i := IdentitySet with: 'module' copy.
      {
              s = i.
              i = s
      }

      The old implementation would return #(false true), while the new one evaluates to #(false false).


Right.  That's a pain, but fair enough.  This is clumsy: (aSet size = 1 and: [aSet anyOne = #module]).  This slightly less so:  aSet = (aSet
species with: #module).

You could also write it as

aSet asArray = #(module).

or as

(aSet as: Set) = (Set with: #module).

Expensive when aSet is large.  I've gone with the anyOne form.

 
Levente



      Levente

            _,,,^..^,,,_
            best, Eliot


_,,,^..^,,,_
best, Eliot

_,,,^..^,,,_
best, Eliot


Reply | Threaded
Open this post in threaded view
|

Re: set equality has changed :-(

Eliot Miranda-2
In reply to this post by Tobias Pape
Hi Marcel,

On Tue, Apr 19, 2016 at 12:32 AM, Tobias Pape <[hidden email]> wrote:

On 19.04.2016, at 08:23, marcel.taeumel <[hidden email]> wrote:

> Hi Eliot,
>
> try this:
> (Set with: #module) includesAllOf: (IdentitySet with: #module).
>
> This is "hasEqualElements:" for all kinds of collections.

But this is not reflexive, right?

(Set withAll: #(module moep)) includesAllOf: (IdentitySet with: #module)

How about

Set>>hasEqualElements: aCollection
     ^aCollection size = self size and: [aCollection noneSatisfy: [:element| (self includes: element) not]


Again it's not reflexive with sequenceable collections, but unlike includesAllOf: it meets the specification ;-).



>
> Best,
> Marcel







--
_,,,^..^,,,_
best, Eliot


Reply | Threaded
Open this post in threaded view
|

Re: set equality has changed :-(

Tobias Pape

On 19.04.2016, at 18:11, Eliot Miranda <[hidden email]> wrote:

> Hi Marcel,
>
> On Tue, Apr 19, 2016 at 12:32 AM, Tobias Pape <[hidden email]> wrote:
>
> On 19.04.2016, at 08:23, marcel.taeumel <[hidden email]> wrote:
>
> > Hi Eliot,
> >
> > try this:
> > (Set with: #module) includesAllOf: (IdentitySet with: #module).
> >
> > This is "hasEqualElements:" for all kinds of collections.
>
> But this is not reflexive, right?
>
> (Set withAll: #(module moep)) includesAllOf: (IdentitySet with: #module)
>
> How about
>
> Set>>hasEqualElements: aCollection
>      ^aCollection size = self size and: [aCollection noneSatisfy: [:element| (self includes: element) not]
>
>
> Again it's not reflexive with sequenceable collections, but unlike includesAllOf: it meets the specification ;-).

I think I was incorrect, I think what I meant is commutative.

Best
        -Tobias

>
>
>
> >
> > Best,
> > Marcel