Jump to content

Module:Math

විකිපීඩියා වෙතින්
05:25, 21 පෙබරවාරි 2013 වන විට en>Banaticus (created random module) විසින් සිදු කර ඇති සංශෝධන
(වෙනස) ← පැරණි සංශෝධනය | වත්මන් සංශෝධනය (වෙනස) | නව සංශෝධනය → (වෙනස)
local mathy = {}

function mathy.random( frame )
    first = tonumber(frame.args[1]) -- if it doesn't exist it's NaN, if not a number it's nil
    second = tonumber(frame.args[2])

    if first then -- if NaN or nil, will skip down to final return
        if first <= second then -- could match if both nil, but already checked that first is a number in last line
            return math.random(first, second)
        end
        return math.random(first)
    end   
    return math.random()
end
"https://si.wikipedia.org/w/index.php?title=Module:Math&oldid=522144" වෙතින් සම්ප්‍රවේශනය කෙරිණි