Reference:Country
From Metabolomics.JP
(Difference between revisions)
| Line 6: | Line 6: | ||
local list = {}; | local list = {}; | ||
local hash = {}; | local hash = {}; | ||
| + | local count = {}; | ||
for word in stdin:gmatch("%S+") do | for word in stdin:gmatch("%S+") do | ||
| − | num, name = string.match(word,[0-9]+:[%a_]+); | + | num, name = string.match(word,"([0-9]+):([%a_]+)"); |
table.insert(list, num); | table.insert(list, num); | ||
if (hash[num] == null) then | if (hash[num] == null) then | ||
| − | hash[num] = name; | + | hash[num] = name; count[num] = 1; |
else | else | ||
| − | hash[num] = hash[num] .. "," .. name; | + | hash[num] = hash[num] .. ", " .. name; |
| + | count[num] = count[num] + 1; | ||
end | end | ||
end | end | ||
| − | + | table.sort(list); | |
| − | + | local i=0; | |
| + | local output = ""; | ||
| + | while(i < 10) do | ||
| + | num = table.remove(list); | ||
| + | name = hash[num]; | ||
| + | i = i + count[num]; | ||
| + | output = output .. "\n" .. name .. " " .. num; | ||
end | end | ||
| + | print(output); | ||
|{{#repeat:List_Country/CountAuthor|1|{{#var:countryNames}}}} | |{{#repeat:List_Country/CountAuthor|1|{{#var:countryNames}}}} | ||
}} | }} | ||
Revision as of 10:49, 10 September 2008
This page lists the country of the authors.
./lua: /tmp/mw_ex_lua_9guyqQ:20: attempt to perform arithmetic on field '?' (a nil value)