User:Fivesteaks: Difference between revisions
Jump to navigation
Jump to search
Fivesteaks (talk | contribs) Created page with "Test pages: Module:FivesteaksPersistentTest" |
Fivesteaks (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
Test pages: | Test pages: | ||
[[Module:FivesteaksPersistentTest]] | [[Module:FivesteaksPersistentTest]] | ||
Lua test: | |||
<lua> | |||
function bottle(x) | |||
if x > 1 then | |||
return x .. " bottles of beer" | |||
elseif x == 1 then | |||
return "One bottle of beer" | |||
else | |||
return "No more bottles of beer" | |||
end | |||
end | |||
function count(x) | |||
output = "<pre>" | |||
for beer = x, 1, -1 do | |||
output = output .. bottle(beer) .. " on the wall,\n" | |||
output = output .. bottle(beer) .. ",\n" | |||
output = output .. "Take one down, pass it around,\n" | |||
output = output .. bottle(beer-1) .. " on the wall.\n" | |||
output = output .. "\n\n" | |||
end | |||
return output .. "</pre>" | |||
end | |||
</lua> | |||
==99 Bottles of Beer== | |||
{{#luaexpr:count(99)}} |
Revision as of 04:10, 1 November 2016
Test pages: Module:FivesteaksPersistentTest
Lua test: <lua> function bottle(x)
if x > 1 then return x .. " bottles of beer" elseif x == 1 then return "One bottle of beer" else return "No more bottles of beer" end
end
function count(x)
output = "
" for beer = x, 1, -1 do output = output .. bottle(beer) .. " on the wall,\n" output = output .. bottle(beer) .. ",\n" output = output .. "Take one down, pass it around,\n" output = output .. bottle(beer-1) .. " on the wall.\n" output = output .. "\n\n" end return output .. "
"
end </lua>
99 Bottles of Beer
{{#luaexpr:count(99)}}