翻訳と辞書
Words near each other


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

モジュール:Roman : ウィキペディア日本語版
モジュール:Roman
-- This module implements .
local p =
-- This function implements the template.
local function overline( s )
return mw.ustring.format( '%s', s )
end
-- Gets the Roman numerals for a given numeral table. Returns both the string of
-- numerals and the value of the number after it is finished being processed.
local function getLetters( num, t )
local ret =
for _, v in ipairs( t ) do
local val, letter = unpack( v )
while num >= val do
num = num - val
table.insert( ret, letter )
end
end
return table.concat( ret ), num
end
-- The main control flow of the module.
local function _main( args )
-- Get input and exit displaying nothing if the input is bad.
local num = tonumber( args1 )
if not num or num < 1 or num == math.huge then
return
end
num = math.floor( num )

-- Return a message for numbers too big to be expressed in Roman numerals.
if num >= 5000000 then
return args2 or 'N/A'
end

local ret = ''
-- Find the Roman numerals for the large part of numbers 5000 and bigger.
-- The if statement is not strictly necessary, but makes the algorithm
-- more efficient for smaller numbers.
if num >= 5000 then
local bigRomans =
local bigLetters
bigLetters, num = getLetters( num, bigRomans )
ret = overline( bigLetters )
end

-- Find the Roman numerals for numbers 4999 or less.
local smallRomans =
local smallLetters = getLetters( num, smallRomans )
ret = ret .. smallLetters

return ret
end
function p.main( frame )
-- If called via #invoke, use the args passed into the invoking
-- template, or the args passed to #invoke if any exist. Otherwise
-- assume args are being passed directly in from the debug console
-- or from another Lua module.
local origArgs
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
for k, v in pairs( frame.args ) do
origArgs = frame.args
break
end
else
origArgs = frame
end
-- Trim whitespace and remove blank arguments.
local args =
for k, v in pairs( origArgs ) do
if type( v ) == 'string' then
v = mw.text.trim( v )
end
if v ~= '' then
args = v
end
end
return _main( args )
end
return p


抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「モジュール:Roman」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.