[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: string array
- From: Roberto Ierusalimschy <rieru@...>
- Date: Fri, 8 Feb 2002 09:16:04 -0600 (CST)
On Fri, 8 Feb 2002, Bansard Stephane wrote:
> Could anyone tell me how to write a function to create a string array
> (like the %w notation in ruby or Perl) ? (or redirect me to the right place in
> the doc!)
> ex: f(a, b, c) would return {"a", "b", "c"}
You can write something like «f'a b c'», and then it is easy to code `f':
function f (s)
local res = {}
gsub(s, '(%w+)', function (w) tinsert(res, w) end)
return res
end
(Actually, it is a "split" function...)
-- Roberto