Support of algebraic operations on sets
Bert Freudenberg
bert at freudenbergs.de
Fri Jun 15 18:03:23 UTC 2007
On Jun 15, 2007, at 19:33 , Bert Freudenberg wrote:
> 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.
Could we agree that in a union, each element will only be there
exactly once? This is why the 3.8 implementation of #union: on
Dictionary is buggy:
| a b |
a := {$a->1. $b->2} as: Dictionary.
b := {$c->1. $d->2} as: Dictionary.
(a union: b) count: [:x | x = a anyOne]
"= 2"
- Bert -
More information about the Squeak-dev
mailing list
|