AJLogo Math



This describes Math in AJLogo.
Please feel free to send mail or chat with me at the site.
Cheers,
Arnie
 
The math in AJLogo is in prefix notation.
= a 55    is an example of assignment using prefix notation
= a + 33 22    adds 22 to 33 and assigns the value to a
++a  increments a (adds 1 to a)
Generally all Java math is available (including *,/,trig, exp, int, rounded int, ceiling, floor, random)

* Flow control
if, elsif, else example:
if(a){ pr "a is true" }elsif(b){ pr "a is false and b is true" } else { pr "a and b are false" }

while loop example:
while (<a 5){ pr "a is less than 5" = a  + a 2 }

for loop example:
for(== a 0;< a 5; ++a){ pr "a is less than 5" }
The plus sign in is:"+a  is used to join the string and a together for the print.

rp repeat  mentioned earlier this is AJLogo's simple loop method, let's use it for a little more complicated example:
cs =a 10 rp 360[ fd a rt 10 +=a .1 ]
This will draw a spiral.

           
Monday, 15-Oct-2018 13:40:52 UTC