Support of algebraic operations on sets

sig siguctua at gmail.com
Sat Jun 16 08:57:30 UTC 2007


On 15/06/07, Bert Freudenberg <bert at freudenbergs.de> wrote:
>
> On Jun 15, 2007, at 19:23 , sig wrote:
>
> > On 15/06/07, Bert Freudenberg <bert at freudenbergs.de> wrote:
> >> On Jun 15, 2007, at 18:58 , sig wrote:
> >>
> >> > Lets take an example from real life: we have two dictionaries with
> >> > translation of words from one language into another.
> >>
> >> book1 := {'hi'->'ho'. 'mu'->'ma'} as: Dictionary.
> >> book2 := {'hi'->'ho'. 'foo'->'bar'. 'be'-> 'boo'} as: Dictionary.
> >>
> >> > Now, the task is
> >> > to compare these books to find out, what book contains more
> >> > translations
> >>
> >> book1 size > book2 size
> >>
> >> > and to find out what words is missing in first book that
> >> > holds second one.
> >>
> >> new := book2 keys difference: book1 keys
> >>
> >> > Then, after finding them out, merge new words with
> >> > first book.
> >>
> >> new do: [:k | book1 at: k put: (book2 at: k)].
> >
> > instead of:
> >  book1 union: book2
>
> >>
> >> > Or remove them from second book.
> >>
> >> new do: [:k | book2 removeKey: k].
> >>
> > instead of:
> >  book2 difference: (book1 intersection: book2)
> >
> >
> > can't you see the difference?
>
> Sure. As I said before, you seem to think of Dictionaries as
> Collections of Associations. So just use a Collection of Associations:
>
> | book1 book2 new |
> book1 := {'hi'->'ho'. 'mu'->'ma'}.
> book2 := {'hi'->'ho'. 'foo'->'bar'. 'be'-> 'boo'}.
> book1 union: book2.
> book2 intersection: book1.
>
> But for *Dictionaries* these semantics would be nonsensical.
>

Hmm.. what of my statements has lead you to this conclusion? On the
contrary, I tried to show you that current behavior of Dictionary in
squeak is something like you describing and that's what i don't like.


> - Bert -
>
>
>
>



More information about the Squeak-dev mailing list