(1 to: self) inject: 1 into: #*
Henrik Gedenryd
Henrik.Gedenryd at lucs.lu.se
Thu Jan 20 11:58:34 UTC 2000
Dan Ingalls wrote:
> One of the reasons we didn't actually act on these suggestions on the last
> go-round was that we got distracted by extending Squeak's numeric coercions to
> handle collections enabling APL-like examples as
>
> #(1 2 3 4 5) * 2
> and
> 2 * #(1 2 3 4 5).
This seems the appropriate context to consider set operations on
collections, such as union and difference:
#(1 2 3 4 5) asSet union: #(5 6) asSet ==>> Set (1 2 3 4 5 6)
#(1 2 3 4 5) asSet intersect: #(5 6) asSet ==>> Set (5)
This would handle removing and detecting duplicates and such, which seems to
crop up from time to time.
As a matter of fact, I would interpret + etc. on sets as set algebraic
operators:
set1 + set2 equivalent to set1 union: set2
but this might certainly obfuscate.
The semantics of the operation would depend on the class of the receiver
(unlike sets, arrays etc. would not remove duplicates on union:).
To me, this seems another obvious candidate for having been previously
considered as well.
Also, is there a reason why there can't be a final period in a { } set
constructor? This seems inconsistent with periods in blocks and methods.
(Not too big a deal.)
ie. {1. 2.} bad; {1. 2} ok
Henrik
More information about the Squeak-dev
mailing list
|