|
|
Wasn't it Max Ulbrich who wrote:
>Hi,
>
>I just trying to get started with Povray and try to sum elements of an
>array.
>If I use elem[0]+elem[1]+elem[2]+... it works fine.
>If I try sum(i,1,n,elem[i]) I get an error.
sum() only works inside a function{} and array[] references don't work
inside a function{}. So, whether you're trying to do the sum inside or
outside a function{} it's not going to work.
I think you have to use a loop:
#declare i=1;
#declare Sum=0;
#while (i<=n)
#declare Sum = Sum + elem[i];
#declare i=i+1;
#end
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|