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

Re: [StrongED] Roman numerals



In message <mpro.ouqmja002a56b0244.pittdj@xxxxxxxxxxxx>
          David Pitt <pittdj@xxxxxxxxxxxx> wrote:

> sumnums has more than one issue. adding 'require' as in :-
>
> in require "lpeg"
>
> helped, [well done !] but it now falls over at line 12.

I cannot put my finger on sumnums - must have it somewhere, I
suppose. If it is meant to add up all the positive integers
occurring in a text then this ought to do as an unsophisticated
zero-approximation:

#! lua
local n = 0
for line in io.lines (arg[1]) do
  for x in line:gmatch "%d+" do n += tonumber (x) end -- for
end -- for
print "Total = ", n

-- 
Gavin Wraith (gavin@xxxxxxxxxxxxxxx)
Home page: http://www.wra1th.plus.com/

--=20
To unsubscribe send a mail to StrongED+unsubscribe@xxxxxxxxxxx
List archives at http://www.Torrens.org/RO/StrongED/index.html