comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: recursive routine
items: Re: recursive routine

recursive routine
type: item
description: 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
creator: Thibault Garel
date: 2013-04-08T09:21:37-00:00

Re: recursive routine
type: item
description: 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
creator: Matthew Argall
date: 2013-04-11T13:11:01-00:00

Re: recursive routine
type: item
description: 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.
creator: Matthew Argall
date: 2013-04-11T13:22:55-00:00