Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!tektronix!tekcrl!tekgvs!jans From: jans@tekgvs.LABS.TEK.COM (Jan Steinman) Newsgroups: comp.lang.smalltalk Subject: Re: Smalltalk (maybe only Smalltalk/V) quest. Message-ID: <5068@tekgvs.LABS.TEK.COM> Date: 4 May 89 21:15:35 GMT Distribution: usa Organization: Tektronix Inc., Beaverton, Or. Lines: 16 <... a program... that counts the occurrences of letters in an input string...> How about (for Tek Smalltalk, but should be similar in V): d _ Dictionary new. (FillInTheBlank request: 'enter line') do: [:c | d at: c put: (d at: c ifAbsent: [0]) + 1]. ^d I'd encourage anyone beginning at Smalltalk to play with Dictionary. People who are used to C/Pascal/FORTRAN/BASIC don't think much about key-value pairs, although Lispers usually pick up on it quickly. :::::: Jan Steinman - N7JDB Electronic Systems Laboratory :::::: :::::: jans@tekgvs.LABS.TEK.COM Box 500, MS 50-370 (w)503/627-5881 :::::: :::::: jsteinma@caip.RUTGERS.EDU Beaverton, OR 97077 (h)503/657-7703 ::::::