On Fri, Nov 22, 2002 at 06:56:05AM +0900, MetalOne wrote:
> Thomas Gagn? <tgagne / wide-open-west.com> wrote in message news:<3DDCFB97.1040505 / wide-open-west.com>...
> > Do I have the Smalltalk version right?
> > 
> > size := 640*480*2.
> > image := ByteArray new: size withAll: 0.
> > lookup := ByteArray new: size withAll: 0.
> > 
> > Time millisecondsToRun: [
> > 	1 to: size do: [ :i |
> > 		image at: i put: (lookup at: (image at: i ) + 1)
> > 	]
> > ]
> > 
> > "159"
> 
> 
> I don't know smalltalk, but it looks close enough.
> I don't see the reason for the + 1.

The index of the first element of an array in Smalltalk is 1.
He could have omitted it and simply initialize the lookup table w/
another value, but it'd have been unfair :)

BTW, in Squeak, on a 1700+ Athlon XP, that code snippet runs in 260ms. 

> The lookup table was actually only 1024 elements, but it doesn't really matter.
> What kind of processor did you run the test on.

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Turn right here. No! NO! The OTHER right!