[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: comparing Lua with other languages
- From: Wim Couwenberg <w.couwenberg@...>
- Date: Wed, 29 Dec 2004 18:31:02 +0100
Hi,
Wouldn't be easier to use the "simple I/O model"?
Since size matters in this particular test it is *much* better! Below
is a new version. Not submitted yet (you probably have an even shorter
one up your sleeve anyway??)
--
Wim
if not arg[1] then
print(arg[0] .. [[ infile [outfile]
sort lines from infile to outfile or to stdout if no outfile is provided.]])
return
end
io.input(arg[1])
io.output(arg[2]) -- keeps stdout if arg[2] == nil
local lines = {}
for line in io.lines() do
table.insert(lines, line)
end
table.sort(lines)
for _, line in ipairs(lines) do
io.write(line, "\n")
end