Debugging assistance please :-)

Christopher Barham cbarham at pobox.com
Tue Oct 26 11:26:15 UTC 2004


Hi,

I'm fairly new to Squeak and Smalltalk, I've been playing with various
programming snippets to improve my fluency.

I have some Ruby code that generates an Ascii representation of a Mandelbrot
fractal, and thought it may be fun to translate over to squeak.

I've managed to tie myself in knots with a basic syntax error, and I can't
spot it - can anyone mentor me and point me towards the error?  It's driving
me nuts :-)

Here's the code:

createFractal
    "Generate a MandelBrot image using only ASCII chars"
    | d e b r n h |
e := 1.1.
(e > -1.2) whileTrue:
    [ b := -2.0.
    (b < 1.0) whileTrue:
        [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.
              ].
          b := b + 0.04.
          Transcript show:
             (Character value: ((b > 1) ifTrue: [10] ifFalse: [h]) )
          ].
     e := e - 0.1 .
]

The original Ruby code is:

#!/usr/bin/ruby

e = 1.1
while e > -1.2
    b = -2.0
    while b < 1.0
        r = n = 0.0
        h = 127
        while (r*r + n*n < 4.0) and ( (h-=1) > 32)
            d = r
            r = r*r-n*n+b
            n = 2*d*n+e
        end
        b += 0.04
        putc b>1 ? 10 : h
    end
    e -= 0.1
End

Thanks in advance!

Chris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2113 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20041026/4f2167f4/smime.bin


More information about the Squeak-dev mailing list