How to impress the locals...

Daniel Salama dsalama at user.net
Sun Jul 17 03:01:50 UTC 2005


These are all really cool, specially for newcomers into Smalltalk. It  
would be nice to have some public repository of such "show off  
tricks" (which really are helpful short algorithms for day-to-day  
programming).

- Daniel

On Jul 16, 2005, at 6:08 PM, Randal L. Schwartz wrote:

>>>>>> "Alan" == Alan Lovejoy <squeak-dev.sourcery at forum-mail.net>  
>>>>>> writes:
>>>>>>
>
> Alan>             #(9 2 4 12 -3 44) inject: Infinity positive into:  
> [:min :value |
> Alan> value >= min ifTrue: [min] ifFalse: [value]]
>
> Alan>             #(9 2 4 12 -3 44) inject: Infinity negative into:  
> [:max :value |
> Alan> value <= max ifTrue: [max] ifFalse: [value]]
>
> Those look overly complicated:
>
>     s := #(9 2 4 12 -3 44).
>     max := s allButFirst inject: s first into: [:r :i | r max: i]
>
> If you don't like the allButFirst copy, you can use the original
> set anyway, since the identity element of "s first" will max with
> itself just fine.
>
> -- 
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503  
> 777 0095
> <merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl  
> training!
>
>

Daniel Salama
dsalama at user.net
Voice: (954) 655-8051
Fax  : (954) 252-3988

------------------------

This e-mail contains information which may be confidential and
privileged. Unless you are the addressee (or authorized to
receive for the addressee), you may not use, copy or disclose
to anyone the message or any information contained in the
message.  If you have received the message in error, please
advise the sender by reply e-mail to dsalama at user.net or
tel. +1-954-655-8051 and delete the material from any computer.




More information about the Squeak-dev mailing list