Question: Problem with seq

 

Hi

    The following code displays values of the subscripted variables slf[], a positive integer, and a string variable filler[] which is just a set of spaces depending on how big the corresponding value of slf[] s.  This is to make the printout lined up nicely.  

printf("%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d\n", filler[1],slf[1],filler[2],slf[2],filler[3],slf[3],filler[4],slf[4],filler[5],slf[5],filler[6],slf[6],filler[7],slf[7],filler[8],slf[8],filler[9],slf[9],filler[10],slf[10]);

   This works fine,but thought there might be a better way.  I tried:

printf("%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d\n",seq(filler[k],slf[k],k=1..10));

but this came up with an error message.  Is there  a way of doing this more efficiently?

thanks,   David 

 

Please Wait...