View Single Post
Old 13th February 2010, 15:50   #26
Nitorami
Major Dude
 
Join Date: Mar 2008
Location: Erlangen
Posts: 872
secret features ?

Hi all

Looks like the ns-eel update is quite a construction site... I think Benski owes us a few explanations soon

Just unveiled (by experimenting): conditional loops

while (condition; statement1; statement2; (...) ; ) ;

will execute all statements as long as condition is not zero.

Example - the following code calculates the faculty (result = count!).

result = 1;
count = 4;
while (above(count,0);
result = result * count;
count = count-1;
);

In principle conditional loops can be cobbled together by a normal loop of fixed length, encapsulating all statements by indiviual if() conditions, but that is unelegant and significantly less efficient.

One obvious use could be a quicksort algorithm, which sorts a number of shapes by their z-coordinate, to have them drawn in the right order, so the shapes in the front would actually be drawn in front of those in the back.
Nitorami is offline   Reply With Quote