POV-Ray : Newsgroups : povray.unofficial.patches : complicated functions : Re: complicated functions Server Time
1 Sep 2024 20:17:19 EDT (-0400)
  Re: complicated functions  
From: Warp
Date: 8 Nov 2000 04:57:13
Message: <3a092379@news.povray.org>
Chris Huff <chr### [at] maccom> wrote:
: Another possibly useful feature would be the ability to use variables in 
: the function

  And conditional evaluation and recursive functions.

  When all those three are supported, it will be possible to make fractal
functions (such as mandelbrot, julia... almost any).

  Of course it would need some optimization so that it will not take huge
amounts of memory nor time. Tail recursion optimization is one of the most
obvious and most effective.

  (For those who don't know, tail recursion optimization means that if the
recursive call is the last thing in the function, then the this call doesn't
internally generate a new function call (putting parameters in the stack etc),
but it just jumps to the beginning of the function almost as if it was just
a while-loop. For example, this type of function could be something like:

  #declare Fact = function { x<1 ? 1 : x*Fact(x-1) }

which calculates the factorial of x; since the recursive call is the last
thing in the function, it can be made as a loop instead of recursive
function calling.)

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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