[metapost] Processing comma separated values

Aditya Mahajan adityam at umich.edu
Fri Feb 26 17:37:37 CET 2010


On Fri, 26 Feb 2010, Taco Hoekwater wrote:

> Aditya Mahajan wrote:
>> What is the canonical way of processing a list of comma separated values in 
>> metapost. I want to write a helper macro for the boxes package so that
>
> I do not have time to write a full answer, but the way to
> process a list of argument values is something like this:
>
> def boxsep (text a) =
>   forsuffixes _a=a:
> 	 show _a;
>   endfor
> enddef;

Thanks. Dan Luecking posted a solution offlist that works perfectly.

def boxsep (suffix A,B) (text T) =
   def _prev_suffix = B enddef;
   B.w - A.e
   forsuffixes _S = T:
     = _S.w - _prev_suffix.e
     hide (def _prev_suffix = _S enddef;)
   endfor
enddef;

I had to read the metapost manual carefully to understand why it works.

To metapost,

boxset(a,b)(c,d) is the same as boxset(a,b,c,d).

Thanks you Dan and Taco.

Aditya




More information about the metapost mailing list