Template:ClassMatrix: Difference between revisions
(New page: {{#def:ALL|{{#SearchTitle:{{{1}}} }}}} {{#lua: local H = {}; for id in stdin:gmatch("%w+") do str = string.sub(id,{{{2}}},{{{3}}}); if (H[str] == nil) then H[str] = 1; e...) |
mNo edit summary |
||
(65 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{#def:ALL|{{#SearchTitle:{{{1}}} }}}} | {{#def:ALL|{{#SearchTitle:{{{1}}} }}}} | ||
{{#lua: | {{#def:X-AXIS|{{#lua: | ||
local H = {}; | local H = {}; | ||
for id in stdin:gmatch("% | local T = {}; | ||
for id in stdin:gmatch("%S+") do | |||
str = string.sub(id,{{{2}}},{{{3}}}); | str = string.sub(id,{{{2}}},{{{3}}}); | ||
if (H[str] == nil) then H[str] = 1; | if (H[str] == nil) | ||
then H[str] = 1; table.insert(T, str); | |||
else H[str] = H[str] + 1; | else H[str] = H[str] + 1; | ||
end | end | ||
end | end | ||
for | table.sort(T); | ||
print(k .. | for i=1,table.getn(T) do | ||
local k = T[i]; | |||
print(k .. " " .. H[k]); | |||
end | end | ||
|{{#var:ALL}} | |{{#var:ALL}} | ||
}} | }} | ||
}} | |||
{{#def:Y-AXIS|{{#lua: | |||
local H = {}; | |||
local T = {}; | |||
for id in stdin:gmatch("%S+") do | |||
str = string.sub(id,{{{4}}},{{{5}}}); | |||
if (H[str] == nil) | |||
then H[str] = 1; table.insert(T, str); | |||
else H[str] = H[str] + 1; | |||
end | |||
end | |||
table.sort(T); | |||
for i=1,table.getn(T) do | |||
local k = T[i]; | |||
print(k .. " " .. H[k]); | |||
end | |||
|{{#var:ALL}} | |||
}} | |||
}} | |||
{{#def:MATR| | |||
{{#lua: | |||
local input = stdin:match(".+"); | |||
local xaxis, yaxis, all = string.match(input, "([^&]+)&&([^&]+)&&(.+)"); | |||
local M = {}; | |||
for id in string.gmatch(all,"(%S+)") do | |||
x = string.sub(id, {{{2}}}, {{{3}}}); | |||
y = string.sub(id, {{{4}}}, {{{5}}}); | |||
if (M[x] == nil) then M[x] = {}; end | |||
if (M[x][y] == nil) | |||
then M[x][y] = 1; | |||
else M[x][y] = M[x][y] + 1; | |||
end | |||
end | |||
strFst = string.sub("{{{1}}}", 1, {{{2}}}-1); | |||
strSnd = string.sub("{{{1}}}", {{{3}}}+1, {{{4}}}-1); | |||
strTrd = string.sub("{{{1}}}", {{{5}}}+1, string.len("{{{1}}}")); | |||
for x,v in string.gmatch(xaxis, "(%S+) (%S+)") do | |||
str = x .. " <small>(" .. v .. ")</small>&&"; | |||
for y,v in string.gmatch(yaxis, "(%S+) (%S+)") do | |||
if (M[x][y] == nil) | |||
then str = str .. " 0 dummy"; | |||
else str = str .. " " .. M[x][y] .. " " .. strFst .. x .. strSnd .. y .. strTrd; | |||
end | |||
end | |||
print(str); | |||
end | |||
|{{#var:X-AXIS}}&&{{#var:Y-AXIS}}&&{{#var:ALL}} | |||
}} | |||
}} | |||
{{#var:MATR}} | |||
{| class=wikitable style="margin:0 auto" | |||
|+ style="font-weight:bold" | Rows: {{{6|}}}, Columns: {{{7|}}} (counts) | |||
|- | |||
! | |||
{{#repeat:ClassMatrix/CreateHeader|1|{{#var:Y-AXIS}}}} | |||
{{#repeat:ClassMatrix/CreateRows|1|{{#var:MATR}}}} | |||
|} |
Latest revision as of 14:18, 21 December 2008
{{#lua:
local input = stdin:match(".+"); local xaxis, yaxis, all = string.match(input, "([^&]+)&&([^&]+)&&(.+)"); local M = {}; for id in string.gmatch(all,"(%S+)") do x = string.sub(id, {{{2}}}, {{{3}}}); y = string.sub(id, {{{4}}}, {{{5}}}); if (M[x] == nil) then M[x] = {}; end if (M[x][y] == nil) then M[x][y] = 1; else M[x][y] = M[x][y] + 1; end end strFst = string.sub("{{{1}}}", 1, {{{2}}}-1); strSnd = string.sub("{{{1}}}", {{{3}}}+1, {{{4}}}-1); strTrd = string.sub("{{{1}}}", {{{5}}}+1, string.len("{{{1}}}")); for x,v in string.gmatch(xaxis, "(%S+) (%S+)") do str = x .. " (" .. v .. ")&&"; for y,v in string.gmatch(yaxis, "(%S+) (%S+)") do if (M[x][y] == nil) then str = str .. " 0 dummy"; else str = str .. " " .. M[x][y] .. " " .. strFst .. x .. strSnd .. y .. strTrd; end end print(str); end
|{{#lua:
local H = {}; local T = {}; for id in stdin:gmatch("%S+") do str = string.sub(id,{{{2}}},{{{3}}}); if (H[str] == nil) then H[str] = 1; table.insert(T, str); else H[str] = H[str] + 1; end end table.sort(T); for i=1,table.getn(T) do local k = T[i]; print(k .. " " .. H[k]); end
| }}&&{{#lua:
local H = {}; local T = {}; for id in stdin:gmatch("%S+") do str = string.sub(id,{{{4}}},{{{5}}}); if (H[str] == nil) then H[str] = 1; table.insert(T, str); else H[str] = H[str] + 1; end end table.sort(T); for i=1,table.getn(T) do local k = T[i]; print(k .. " " .. H[k]); end
| }}&& }}
{{#lua:}}! ({{{1}}} () | {{{1}}} () | for (id in stdin:gmatch("%S+") do) | {{{1}}} () | {{{1}}} () | {{{1}}} () | {{{1}}} () | end () | end () | table.sort(T); () | {{{1}}} () | {{{1}}} () | print(k (.. " " .. H[k]);) | end () | () | ()) | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{{#lua:}}|- | {{{1}}} | |||||||||||||||
{{{1}}} | ||||||||||||||||
{{{1}}} | ||||||||||||||||
for id in string.gmatch(all,"(%S+)") do | ||||||||||||||||
{{{1}}} | ||||||||||||||||
{{{1}}} | ||||||||||||||||
{{{1}}} | ||||||||||||||||
{{{1}}} | ||||||||||||||||
{{{1}}} | ||||||||||||||||
{{{1}}} | ||||||||||||||||
end | ||||||||||||||||
end | ||||||||||||||||
{{{1}}} | ||||||||||||||||
{{{1}}} | ||||||||||||||||
{{{1}}} | ||||||||||||||||
for x,v in string.gmatch(xaxis, "(%S+) (%S+)") do | ||||||||||||||||
{{{1}}} | ||||||||||||||||
for y,v in string.gmatch(yaxis, "(%S+) (%S+)") do | ||||||||||||||||
{{{1}}} | ||||||||||||||||
{{{1}}} | ||||||||||||||||
{{{1}}} | ||||||||||||||||
end | ||||||||||||||||
end | ||||||||||||||||
print(str); | ||||||||||||||||
end | ||||||||||||||||
' | ||||||||||||||||
'''' |