lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, 2004-02-05 at 00:01, Asko Kauppi wrote:
> Insteead of the regular "_,_, str= string.find( "  I'm considering 
> using the following functions:

<snip>

> What do you normally do - are there better ways to achive this?

I've used a more generic form in the past:

function n(n, f, ...)
  return ({ f(unpack(arg)) })[n]
end

So you can have foo = n(3, string.find, "Hello World", "ll", 1, 1) etc.

It is a bit ugly, though.
-- 
Rob Kendrick, Pepperfish Ltd.         +44 (0)845 226 4146  www.pepperfish.net
PGP signed or encrypted mail welcome                         Key ID: 3651D17A