[squeak-dev] One liner challenge
Josh Gargus
josh at schwa.ca
Fri Mar 12 15:31:31 UTC 2010
Thanks Alan, that's good to know. I don't much like the name #upToWith: anyway; it was just the first reasonable thing that came to mind.
Cheers,
Josh
On Mar 12, 2010, at 5:17 AM, Alan Knight wrote:
> VisualWorks has that one, as #through:, and the #corresponding throughAll: for a collection argument.
>
> At 11:56 PM 2010-03-11, Josh Gargus wrote:
>> #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]]
>>
>> Cheers,
>> Josh
>>
>>
>> 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
>> >
>
> --
> Alan Knight [|], Engineering Manager, Cincom Smalltalk
> knight at acm.org
> aknight at cincom.com
> http://www.cincom.com/smalltalk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20100312/7d74c42f/attachment.htm
More information about the Squeak-dev
mailing list
|