POV-Ray : Newsgroups : povray.general : Parameters to functions used in expressions ... : Re: Parameters to functions used in expressions ... Server Time
2 Aug 2024 04:24:27 EDT (-0400)
  Re: Parameters to functions used in expressions ...  
From: Vincent LE CHEVALIER
Date: 19 Jan 2005 11:13:28
Message: <41ee8728@news.povray.org>
Slime wrote:
>>Do arrays work in the same way ? I recall having tried to get a value in
>>an array, indexed by a parameter of a function (something like
>>function(x) {myarray[floor(x)]} ) and never being able to find a way to
>>do so...
> 
> 
> Yes; since array elements are evaluated during parse time, the index of the
> array can't be dependant on function arguments which would only be available
> when the function is evaluated. The number within the [] brackets must be
> something that can be evaluated ahead of time, and then the function will be
> equivalent to function(x) {3} or something like that.
> 
> (There are ways, however, to construct a function from an SDL array that
> will work essentially like a lookup on the array. Unfortunately, the lookup
> will be at best an O(log(n)) search instead of an O(1) lookup, and the
> function will take more memory than the original array itself.)
> 
>  - Slime
>  [ http://www.slimeland.com/ ]
> 
> 
OK, thanks for the insight !

-- 
Vincent


Post a reply to this message

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