A newbie needs some help in squeak (maths, algorithm and drawing)

Bert Freudenberg bert at freudenbergs.de
Thu Apr 26 14:37:14 UTC 2007


On Apr 26, 2007, at 16:26 , Christophe Bouchard wrote:

> Hello,
> I have to realize an application in squeak which is an icon  
> generator. My questions are the following:
> I have an algorithm which describe a spiral and i'd like to  
> transcript it into squeak, but it doesn't work.
> The original algorithm is:
> " for( i=0; i < len; i++ ) {
>   theta = 2*pi*float(i) / ppr;
>   r = 0.15 * sqrt(theta);
>   x = r * cos(theta);
>   y = r * sin(theta);
>   }
> "
>
> And what i've done but that doesn't work:
> "
> spiral: len with: ppr
>
> 	| theta r x y |
> 	
> 	0 to: (len-1) do:
> 		[:i | theta = 2* Float pi * i / ppr.
> 			r = 0.15 * (self sqrt: theta).
> 			x = r * ( self cos: theta).
> 			y = r * ( self sin: theta).		
> 		]
> "
>
> But this code doesn't work and I don't know how to code my spiral  
> algorithm and how it will be displayed on screen when running.

Check out classes Scanner, Parser, and Compiler to find out about  
assignment.

Now, on the newbies list, they might have told you to use ":=".

http://lists.squeakfoundation.org/mailman/listinfo/beginners


- Bert -





More information about the Squeak-dev mailing list