Jump to content

Module:Sandbox/Retro: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Let's get cracking with the 'ol "Hello, world!".
FizzBuzz program, small but good step.
Line 1: Line 1:
--A LUA comment, unlike the comments of C++ and Java (which use "//" and "/* */"); and html (which uses "<!-- -->")
-- A LUA comment, unlike the comments of C++ and Java (which use "//" and "/* */"); and html (which uses "<!-- -->")
local p = {} -- p stands for package
local p = {} -- p stands for package


function p.hello( frame )
function p.hello( frame )
return "Hello, world!"
return "Hello, world!"
end

function p.fizzbuzz( frame )
for i = 1, 100 do
outNum = ""
if i % 3 == 0 then
outNum = outNum .. "Fizz"
end
if i % 5 == 0 then
outNum = outNum .. "Buzz"
end
if outNum == "" then
outNum = i
end
mw.log(outNum)
end
end
end



Revision as of 03:32, 13 May 2019

-- A LUA comment, unlike the comments of C++ and Java (which use "//" and "/* */"); and html (which uses "<!-- -->")
local p = {} -- p stands for package

function p.hello( frame )
    return "Hello, world!"
end

function p.fizzbuzz( frame )
    for i = 1, 100 do
        outNum = ""
        if i % 3 == 0 then 
            outNum = outNum .. "Fizz"
        end
        if i % 5 == 0 then
            outNum = outNum .. "Buzz"
        end
        if outNum == "" then
            outNum = i
        end
        mw.log(outNum)
    end
end

return p