links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
DanielVainsenchersMysteries solutions
Last updated at 2:08 pm UTC on 16 January 2006
Part of the solutions – based on an email by Bert Freudenberg to the German Smalltalk users group

  1. How many words are there in a aString?"

    ('a sample string' findTokens: ' ') size

  2. How many different words are there in aString?

    ('a a sample sample string' findTokens: ' ') asSet size

  3. How many appearances are there of each kind of word in aString?

    long answer (OK but does not take in account that there is already a class just for doing this)

    | aDictionary aCollection  aValue |
    aDictionary _ Dictionary new.
    aCollection _ ('a a sample string' findTokens: ' ').
    aCollection do: [:each |
          aValue _ aDictionary at: each ifAbsent: [0].
          aValue _ aValue + 1.
          aDictionary at: each put: aValue].

    short answer

    ('a a sample string' findTokens: ' ') asBag inspect

    You may as well send #sortedElements or #sortedCounts to the result.

  4. see Display
  5. What are the concrete collection classes?
  6. What are Dictionaries? See Dictionary
  7. What is a SystemDictionary? what is it's name? what does it include?
  8. Why is the method gcd: important? what is the best way of finding out the answer to this question?
  9. Look at some source. Right click on it. choose more until you see explain, format, and such. Explain what they and the other menu choices do. Some of them offer you a menu of possibilities. Play with them, explain what they do in general.
  10. What are the control structures in Squeak? (hint: what is similar about #ifTrue:ifFalse:, #whileTrue:, #do:, #inject:into:..... ? what is it that allows them to be control structures? look for that in other messages.)

17: My suggestion:
thisContext method tempNames

where's the rest gone?