Bags vs. Sets
P | N


| aString someWords |

aString := 'Now is the time for all good men to come to the aid of their blah blah blah'.

someWords := Bag new.

(aString findTokens: ' ') do: [:aWord | someWords add: aWord].

someWords

"--> Bag ('blah' 'blah' 'blah' 'men' 'of' 'the' 'the' 'aid' 'their' 'all' 'to' 'to' 'time' 'Now' 'for' 'good' 'is' 'come' )"


someWords := Set new.

(aString findTokens: ' ') do: [:aWord | someWords add: aWord].

someWords

"--> Set ('blah' 'men' 'of' 'the' 'aid' 'their' 'all' 'to' 'time' 'Now' 'for' 'good' 'is' 'come' )"


Previous | Next


Last modified at 7/24/97; 1:41:14 PM
Other Links of Interest
College of Computing | EduTech Institute | GVU Center
Mark Guzdial | Papers | CS 2390 Spring '97 Home Page | STABLE | MMC-CaMILE

Slide Master