POV-Ray : Newsgroups : povray.advanced-users : recursion Server Time
25 Dec 2024 12:35:04 EST (-0500)
  recursion (Message 1 to 3 of 3)  
From: Paul Jones
Subject: recursion
Date: 19 Apr 2000 10:44:24
Message: <38FDC62F.D85DBD1B@psu.edu>
How do I make a macro call itself with out getting an error message such
as "too many nested symbols"?

-paul
-- 



--------------------------------------------------}
Paul Daniel Jones
The Pennslyvania State University

pdj### [at] psuedu
http://research.chem.psu.edu/glassgrp/paul

       C            The way is near, but men
     // \           seek it afar. It is in the
    N    N          easy things, but men seek it
    |    ||         in the difficult things.
    C    C          -Menicius
     \\  /
       C
--------------------------------------------------}


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: recursion
Date: 19 Apr 2000 11:31:03
Message: <38fdd137$1@news.povray.org>
In article <38FDC62F.D85DBD1B@psu.edu> , Paul Jones <pdj### [at] psuedu>  wrote:

> How do I make a macro call itself with out getting an error message such
> as "too many nested symbols"?

You need to add a parameter you pass on to make sure you do not enter an
infinite recursion (or use another method ending the recursion depending on
your algorithm).  There is an example scene using recursive macro calls in
the 'macros' directory (in the 'scenes' directory) called 'pyramid.pov'.


      Thorsten


Post a reply to this message

From: Margus Ramst
Subject: Re: recursion
Date: 19 Apr 2000 12:47:58
Message: <38FDD58A.32CED5CB@peak.edu.ee>
Paul Jones wrote:
> 
> How do I make a macro call itself with out getting an error message such
> as "too many nested symbols"?
> 

You need some parameter to control recursion depth.
The following macro does nothing but call itself recursively R times:

#macro Recurse(R)
  #if(R>0)
     Recurse(R-1)
  #end
#end

Once the counter has hit zero, the parser falls out of all the nested instances.
You may of course add conditions that reset the counter in some instance, and
thus make the macro go into another recursive 'branch'

-- 
Margus Ramst

Personal e-mail: mar### [at] peakeduee
TAG (Team Assistance Group) e-mail: mar### [at] tagpovrayorg


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.