[Kst] Indexed access into vectors ?

Brisset, Nicolas Nicolas.Brisset at eurocopter.com
Fri Jul 1 15:46:20 CEST 2005


> > I was wondering whether it is already possible in 
> expressions (as used 
> > in equations) to access the nth element of a given data vector ?
> 
>   The plan is to support this at some point, but I have no 
> idea what notation to use.  [vector[n]] seems ugly but should 
> be parseable.  [vector(n)] interferes with function calls.  
> [vector{n}] is unusual.  [vector][n] is impossible to 
> distinguish from a possibly common parse error ( != [v1]*[v2]).
I understand that square brackets [] should only be used to delimit
vector names, not to group expressions for precedence or whatever reason
, which should be achieved with parentheses. If that is correct, I do
not think there are cases where parentheses *inside* square brackets
could be used for function calls. Hence, [vector(n)] seems right to me,
i.e. fairly intuitive and reliably parseable :-)

>   I guess we also return NAN if the index is non-integer or 
> out-of-range?
I'd say round the index to int part in the first case, and NAN in the
second seems appropriate.

Nicolas


More information about the Kst mailing list