blob: 6beeb6a97914a1cb2a489e9a10a6b8050b38744c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/opt/local/bin/lua
--
-- See ../README.md
--
--
-- Run as: lua ch-2.lua < input-file
--
local longest = ""
for line in io . lines () do
--
-- Find words with their letters in lexical order, and which are
-- longer than the longest found so far.
--
if line : lower ()
: find ("^a*b*c*d*e*f*g*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*$")
and line : len () > longest : len ()
then longest = line
end
end
print (longest)
|