[metapost] how to get the size of an array

Hans Hagen pragma at wxs.nl
Wed Aug 1 17:29:47 CEST 2007


Taco Hoekwater wrote:
> Hello,
> 
> Manuel Yguel wrote:
>> Hello,
>> I have two questions:
>>
>> 1) suppose I have an array defined like that
>>
>> numeric range[];
>>
>> rang[1]:=3; ...
>>
>> how can I now the size of this array ?
> 
> You can't, unless you maintain a separate counter yourself. Metapost
> does not actually have arrays, it has structured variables instead.
> The syntax with brackets is a perhaps little misleading; it is shorthand
> for "any numeric expression". For instance, you can skip integers, and
> use negative, and even fractional values.

if you're using a loop to run over the 'array' then you can use a 
known() test and do an exitloop

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the metapost mailing list