We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
concat ?? (Read 529 times)
concat ??
Mar 28th, 2009, 6:46pm
 
this doesn't work:

Code:

void setup(){
 int x = 5;
 Point[] points = new Point[x*3];
 Point[] points1 = new Point[x];
 Point[] points2 = new Point[x];
 Point[] points3 = new Point[x];
 
 // define the 1,2,3 arrays in a loop
 for(int i=0; i<4; i++){
   points1[i] = new Point(random(3), random(3));
   points2[i] = new Point(random(3), random(3));
   points3[i] = new Point(random(3), random(3));
 }
 
 points = concat(points1, points3, points2);
}

class Point{
  float x, y;
  Point(float x, float y){
     this.x = x;
     this.y = y;
  }
}


The error message is:

The method concat(boolean[], boolean[]) in the type PApplet is not applicable for the arguments ( Point[], Point[], Point[] )

So how do I concat multiple arrays that are of my own types?

Undecided
Re: concat ??
Reply #1 - Mar 29th, 2009, 12:22am
 
concat is defined for two arrays only. To concat three arrays, concat the first two, then the last one to the previous result.
Re: concat ??
Reply #2 - Mar 29th, 2009, 2:42am
 
Point[] all_points = (Point[])concat( points1, points2 );

you need to cast the result to the type of array you need.

F
Re: concat ??
Reply #3 - Mar 29th, 2009, 10:46am
 
thanks!
Page Index Toggle Pages: 1