Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Hi, I am having a hard time to figure out how to write a recursive routine for the case below. I have 2 arrays of similar size that contain integers. For the value 2 of A: (a) I want to find the corresponding elements of B, B[i]. (b) Then, I search for the values of A that are equal to the B[i] values found in step (a) (c) repeat step (a) with new A values and so on Example: A = [2, 7, 6, 2, 0] B = [6, 3, 1, 4, 6] (a) A[0] and A [3] have value 2 => the corresponding B elements are B[0]=6 and B[3]=4 (b) the value 4 is not found in A (b) the value 6 is found in A : A[2]=1 (c) value 1 does not exist in B I could easily write the algorithm in this simple example (using the where function), but cannot make it work with much larger arrays in case of N "levels" , i.e. all the steps have to be repeated N times because several elements match the condition at each step. I guess that I should use a recursive routine... (?) Any help much appreciated ! Thanks
I have a program called "ismember.pro" that does what you want for 1 iteration. You could put it in a loop... https://dl.dropboxusercontent.com/u/42944960/ismember.pro
On Thursday, April 11, 2013 9:11:01 AM UTC-4, Matthew Argall wrote: > I have a program called "ismember.pro" that does what you want for 1 iteration. You could put it in a loop... > > > > https://dl.dropboxusercontent.com/u/42944960/ismember.pro Actually, I think this is exactly what you need and that you only need to call it once. I have been pretty lazy this morning and did not read your post carefully the first time.