|
-- This module implements . It converts numbers to old Armenian -- numerals, for numbers from 1-29999. local p = function p.main( frame ) -- If we are being called from #invoke, then the number is the first positional -- argument. If not, it is the frame parameter. local num if frame == mw.getCurrentFrame() then num = frame:getParent().args1 local frameArgsNum = frame.args1 if frameArgsNum then num = frameArgsNum end else num = frame end -- Convert the input to an integer if possible. if type( num ) ~= 'number' then num = tonumber( num ) end if not num then return end num = math.floor( num ) -- Exit if the number is not expressible in Armenian numerals. -- FIXME: Check if Armenian numerals can really be made 10,000x bigger through -- overlining them as it says in our article. (That claim is unsourced.) If they -- can, there is code at Module:Roman that can be stolen from to make it work. if num < 1 or num > 29999 then return end local numerals = local ret = for _, v in ipairs( numerals ) do local val, letter = unpack( v ) while num >= val do num = num - val table.insert( ret, letter ) end end return table.concat( ret ) end return p 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「モジュール:Armenian」の詳細全文を読む スポンサード リンク
|