POV-Ray : Newsgroups : povray.advanced-users : <no subject> : Re: <no subject> Server Time
20 May 2024 07:37:13 EDT (-0400)
  Re: <no subject>  
From: Tor Olav Kristensen
Date: 3 Jul 2023 20:50:00
Message: <web.64a36b886f92e856ba2b3ee089db30a9@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> So, I had some experiments I wanted to try, but I need to make some functions
> that are based on other functions.
> In order to vary what base function I use, I have to do that with a macro, which
> seems to work fine, but I seem to be missing something, either in the creation
> syntax or the invocation syntax.
>
>
> #declare Zero = function (N) {0}
> #declare One = function (N) {1}
>
>
> #macro MakeFunction (Function)
>  function {Function (0) + 1}
> #end
>
> #declare Two = MakeFunction (One);
>
> #debug concat( "Zero = ", str (Zero (10), 0, 3), "\n")
> #debug concat( "One = ", str (One (10), 0, 3), "\n")
>
> #declare Val = Two (10);
>
> #debug concat( "Two = ", str (Val, 0, 3), "\n")
>
> That gets me:
>
> Parse Error: Expected 'numeric expression', ) found instead
>
> I have yet to find a way around that.  Though I could swear that I've done
> something similar to this before....
>
>
> Does anyone have any ideas?

Try this:


#macro MakeFunction(Fn)

    function(N) { Fn(0) + 1 }

#end // macro MakeFunction


--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

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