Javascript recursion

voxdeserti's picture

Hello! Cannot make this JS work. The result should be 10 9 8 7 6 5 4 3 2 1 0 Help please!

voxdeserti's picture
Re: Javascript recursion

)

PreviewAttachmentSize
JS_recursion.qtz33.97 KB

krrkt's picture
Re: Javascript recursion

points = new Array();
 
function (__structure Point_struct) main ()
{
   var result = new Object();
 
   recurs(10);
 
   result.Point_struct = points;
 
   return result;
}
 
 
function recurs( p1 ) {
 
  points = new Array();
 
  for( var i = 0; i < p1; i++ ) {
 
     points.push( p1 - i );
 
  }
}

I personally wouldn't let the recurs method run in the main function, but let it be triggered by a pulse somewhere.

voxdeserti's picture
Re: Javascript recursion

This example doesn't contain recursion... My task is actually to build an L-tree by means of QC just like in this link http://processing.org/learning/topics/tree.html

voxdeserti's picture
Re: Javascript recursion

Yes, this is exactly it. But I wanted to program this algorhythm using Javascript patch.