[squeak-dev] One liner challenge
josh at schwa.ca
Fri Mar 12 04:56:46 UTC 2010
#upTo: is inconvenient for this because the result doesn't include the matched character. If we had #upToWith: we could write:
| in | in := 'This is a (string) with some (parenthetical fields)' readStream.
String streamContents: [:out | [in atEnd] whileFalse: [out nextPutAll: (in upToWith: $( ); nextPutAll: (in upToWith: $) ) asUppercase]]
On Mar 11, 2010, at 7:34 PM, Randal L. Schwartz wrote:
>>>>>> "Travis" == Travis Griggs <travisgriggs at gmail.com> writes:
> Travis> Given strings of the form
> Travis> 'This is a (string) with some (parenthetical fields)'
> Travis> turn them into
> Travis> 'This is a (STRING) with some (PARENTHETICAL FIELDS)'
> Somehow, I think streams and #upTo: are gonna be the key there.
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
> See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
More information about the Squeak-dev