## Support of algebraic operations on sets

Ron Teitelbaum Ron at USMedRec.com
Fri Jun 15 16:16:18 UTC 2007

```Why can't we use both keys and values?

at: #A put: 1;
at: #B put: 1;
at: #C put: 2;
at: #D put: 2;
yourself.

at: #B put: 1;
at: #C put: 1;
at: #D put: 2;
at: #E put: 2;
yourself.

#(#B->1 #D->2)

#(#A->1 #C->2)

#(#C->1 #E->2)

#(#A->1 #C->#(1 2) #E->2)

#(#A->1 #B->1 #C->#(1 2) #D->2 #E->2)

Wouldn't this make the most sense for dictionaries?  I know the values of
the resulting dictionary need special handling but wouldn't a developer
expect to have to handle this situation this way?

Everything else seems to leave out valuable information.

Ron Teitelbaum

> From: sig
>
> On 15/06/07, Klaus D. Witzel <klaus.witzel at cobss.com> wrote:
> > On Fri, 15 Jun 2007 15:50:54 +0200, Bert Freudenberg wrote:
> > > On Jun 15, 2007, at 14:45 , sig wrote:
> > >
> > >> actually i missing these operations for dictionaries.
> > >> in current implementation if you diff/union on two dictionaries,
> > >> you'll find out that associations play role as set elements, not
> keys.
> > >>
> > >> for dictionaries 'a difference: b' i get not exactly what i would
> > >> expect.
> > >
> > > Dictionaries are like other collections - a collection of "elements"
> > > (the values). The keys are only interesting for accessing - like
> indices
> > > on Arrays.  #do: operates on the values. So does #select:, and
> > > #difference:. You wouldn't expect #difference: on an Array to work on
> > > its indices, would you?
> >
> > Good argument. And if some solves that by (aDict keys op: bDict keys)
> and
> > aDict's values are completely different from bDict values, no cDict can
> > hold the "correct" values unless cDict is empty under all circumstances
> ;-)
> >
> > /Klaus
> In my work i must maintain same number of keys in one dictionary as in
> other, while their values are totally different. So, when first
> dictionary changed somehow, then later i need to sync keys with second
> one, but not values, because they constructed by other means. And
> thats where set operations on keys only is useful.

```