Module:User:Amb1ament0/debug

From Wiktionary, the free dictionary
Jump to navigation Jump to search

This is a private module sandbox of Amb1ament0, for their own experimentation. Items in this module may be added and removed at Amb1ament0's discretion; do not rely on this module's stability.


local export = {}

function export.echo3(frame)
	return frame:getParent():getTitle()
end

function export.echo2(frame)
	text = frame.args["text"]
    return string.gsub(text, "a", mw.ustring.char(0x100001))
end	

function export.echo1(frame)
	text = frame.args["text"]
    return text
end	

function export.echo(frame)
	return frame.args["n"]
end	

function export.check(frame)
	text = frame.args["text"]
    local pe = require("Module:utilities").pattern_escape
    local rep, n = pe(text)
	return n
end	

function export.luaversion(frame)
    return _VERSION
end	

function export.factorial(frame)
	return fact(frame.args["n"])
end	

-- Function to compute factorial
local function fact(n)
    if n == 0 then
        return 1
    else
        return n * fact(n - 1)
    end
end

return export