ASCII Mandelbrot (was: Debugging assistance please :-) )
Yar Hwee Boon
hboon at motionobj.com
Wed Oct 27 04:03:21 UTC 2004
On Wed, 27 Oct 2004 13:36:40 +1000, Christopher Barham <cbarham at pobox.com>
wrote:
> Once running I found that it was extremely slow with Transcript show:
> (probably because the chars had to be converted to strings and then
> flushed), changing things to nextPut: really sped things up. The current
> method code is below. Can anyone suggest anything else I could improve to
> make it more 'Squeak-Like' - I was thinking that sunit tests and a
> little
> refactoring would be useful next step.
>
> "Generate a MandelBrot image using only ASCII characters."
> | d r n h |
> Transcript show: Character cr.
> 1.1
> to: -1.1001
> by: -0.1
> do: [:e |
> -2.0
> to: 0.9601
> by: 0.04
> do: [:b |
> r := 0.0.
> n := 0.0.
> h := 127.
> [r * r + (n * n) < 4.0
> and: [h > 32]]
> whileTrue: [h := h - 1.
> d := r.
> r := r * r - (n * n) + b.
> n := 2 * d * n + e].
> Transcript
> nextPut: (Character
> value: (b > 1
> ifTrue: [13]
> ifFalse: [h]))].
> Transcript show: Character cr]
You are still using #show inside the loop. Just change it to a #nextPut:
or just Transcript cr. Then at the end of your code do a #endEntry to
"flush".
--
Regards
HweeBoon
MotionObj
More information about the Squeak-dev
mailing list
|