comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » recursive routine
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
recursive routine [message #83828] Mon, 08 April 2013 02:21 Go to previous message
Thibault Garel is currently offline  Thibault Garel
Messages: 55
Registered: October 2009
Member
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
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Grid help
Next Topic: object serialization in IDL?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:52:35 PDT 2025

Total time taken to generate the page: 0.00387 seconds