[Tutor] Invoking a procedure with an uknown number of arguments...

Lars Erik Gullerud lerik at nolink.net
Fri Mar 23 15:55:42 CET 2007


Hello list,

I have the following problem; I have a list with an unknown number of 
strings, like so:

   MyList = ['string1', 'string2', 'string3'..'stringN']

Now, I need to call a procedure from a 3rd party module (which is just a 
wrapper around a C library), where each of these strings must be passed 
as a separate argument, i.e.

   MyProc(arg1, arg2, arg3..argN)

So, the question is basically, how can I invoke this procedure and pass 
each of these list elements as separate arguments, when I don't know in 
advance how many elements there will be? Had this been e.g. a case with 3 
elements, I could hardcode it like:

   MyProc(MyList[0], MyList[1], MyList[2])

...however this is obviously not possible when the number of elements is 
not known in advance.

Any tips?

/leg


More information about the Tutor mailing list