|
|
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
|
|