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

Re: Recursive function/procedure
type: item
description: Tri VU KHAC wrote: > > Hi folks, > How to write a recursive function/procedure ? > What are programming problems of this technique in IDL ? > Thanks for help. > Best regards, > Tri since the first question has been answered let me address the second one: as always with recursive procedures, you must take care not to run into infinite loops (and there is some limitation as to how many recursions you can make although I don't know the number now). Hence, a "safe" recursive procedure would look like this: pro recurse,level MAX_LEVEL = 1000 ; or whatever is reasonable if (n_elements(level) eq 0) then level = 0 ; main entry level if (level gt MAX_LEVEL) then begin message,'Maximum number of iterations exceeded!' ; optional + ,/Continue return endif ; *** do your stuff here recurse,level+1 ; *** do more stuff here return end Regards, Martin. -- ------------------------------------------------------------ ------- Dr. Martin Schultz Department for Engineering&Applied Sciences, Harvard University 109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA phone: (617)-496-8318 fax : (617)-495-4551 e-mail: mgs@io.harvard.edu Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/ ------------------------------------------------------------ -------
creator: Martin Schultz
date: 1999-04-23T07:00:00-00:00

Re: Recursive function/procedure
type: item
description: In article <372050FC.85669B9@info.fundp.ac.be>, Tri VU KHAC <tvk@info.fundp.ac.be> wrote: > Hi folks, > How to write a recursive function/procedure ? > What are programming problems of this technique in IDL ? > Thanks for help. > Best regards, > Tri > > Tri, I have a couple of sections of using recursion (procedures, functions and methods!) in my new book. Check out my web site at www.rlkling.com for details. -Ronn -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
creator: ronn
date: 1999-04-23T07:00:00-00:00

Re: Recursive function/procedure
type: item
description: In article <7fpsdj$pel$1@nnrp1.dejanews.com>, wbiagiot@suffolk.lib.ny.us wrote: > Tri VU KHAC <tvk@info.fundp.ac.be> wrote: >> Hi folks, >> How to write a recursive function/procedure ? >> What are programming problems of this technique in IDL ? >> Thanks for help. >> Best regards, >> Tri >> I have a recursive program on my site at http://www.ivsoftware.com/. Select the IDL Code link and look for bitex. -- Mike Schienle Interactive Visuals, Inc. mgs@ivsoftware.com Remote Sensing and Image Processing http://www.ivsoftware.com/ Analysis and Application Development
creator: mgs
date: 1999-04-23T07:00:00-00:00

Re: Recursive function/procedure
type: item
description: Tri VU KHAC <tvk@info.fundp.ac.be> wrote: > Hi folks, > How to write a recursive function/procedure ? > What are programming problems of this technique in IDL ? > Thanks for help. > Best regards, > Tri > > Hi Tri, Well, writing a recursive routine is pretty much the same in any language. Here's a quick example: PRO My_routine, My_mode_parameter CASE (My_mode_parameter) OF 0: BEGIN ; Perform all 3 actions My_routine, 1 My_routine, 2 My_routine, 3 END 1: BEGIN <action 1> END 2: BEGIN <action 2> END 3: BEGIN <action 3> END ELSE: ENDCASE END ; PRO Hope this helps. -Bill -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
creator: wbiagiot
date: 1999-04-23T07:00:00-00:00

Re: Recursive function/procedure
type: item
description: Tri VU KHAC wrote: > > Hi folks, > > I did not see anyone tells about this problem: > > function AAA, a,b,C=c,D=d > return, AAA(a, b, C=c, D=d) > end > > Creating this function is very stupid. But the problem is not in this > function. > Writing this function is correct, I think. But if you compile this, the > compilator says there is a syntax error: > > return, AAA(a, b, C=c, D=d) > ^ > Syntax error. > > However, if I do a litle strick: > +remove the two last parameters (c,d) > +compile this function (no error here) > +add the two last parameters (c,d) > +re-compile this function - well, it passes with no error. > > Now this function already works very well. > Could you tell me why ? How to avoid this stupid doing ? > Best regards, Take a look at the FORWARD_FUNCTION command. -- Brian Jackel
creator: Brian Jackel
date: 1999-04-24T07:00:00-00:00

Re: Recursive function/procedure
type: item
description: Hi folks, I did not see anyone tells about this problem: function AAA, a,b,C=c,D=d return, AAA(a, b, C=c, D=d) end Creating this function is very stupid. But the problem is not in this function. Writing this function is correct, I think. But if you compile this, the compilator says there is a syntax error: return, AAA(a, b, C=c, D=d) ^ Syntax error. However, if I do a litle strick: +remove the two last parameters (c,d) +compile this function (no error here) +add the two last parameters (c,d) +re-compile this function - well, it passes with no error. Now this function already works very well. Could you tell me why ? How to avoid this stupid doing ? Best regards, Tri. Tri VU KHAC wrote: > Hi folks, > How to write a recursive function/procedure ? > What are programming problems of this technique in IDL ? > Thanks for help. > Best regards, > Tri
creator: VU KHAC Tri
date: 1999-04-24T07:00:00-00:00