אונטערשייד צווישן ווערסיעס פון "יחידה:גימטריה"

117 בייטן אראפגענומען ,  פֿאַר 9 חדשים
געמאכט אז ב'תקט"ז זאל ווערן 2516 אנשטאט 518, און אראפגענומען אומבאנוצטע פונקציעס
(אימפארטירט פון די העברישע המכלול, זע ביישטייערער ליסטע)
 
(געמאכט אז ב'תקט"ז זאל ווערן 2516 אנשטאט 518, און אראפגענומען אומבאנוצטע פונקציעס)
שורה 36: שורה 36:


local gimatria = function(s)
local gimatria = function(s)
         local sum = 0
    -- Check for a thousands separator (apostrophe)
         for l in mw.ustring.gmatch( s, "." ) do sum = sum + ( values[l] or endet[l] or 0) end
    local thousands, rest = s:match("^(.-)'(.*)$")
         return sum
    if thousands then
        local total = 0
        local thousandsValue = 0
        -- Calculate gematria for the thousands part
        for l in mw.ustring.gmatch(thousands, ".") do
            thousandsValue = thousandsValue + (values[l] or endet[l] or 0)
        end
        total = thousandsValue * 1000
        -- Add gematria for the rest of the number (ignoring extra apostrophes)
        for l in mw.ustring.gmatch(rest, ".") do
            total = total + (values[l] or endet[l] or 0)
        end
        return total
    else
         local total = 0
         for l in mw.ustring.gmatch(s, ".") do
            total = total + (values[l] or endet[l] or 0)
        end
         return total
    end
end
end


שורה 74: שורה 93:
     ['מספר לאותיות'] = function( frame )
     ['מספר לאותיות'] = function( frame )
         return mispar_lotiot( (tonumber(frame.args[1]) or 0),  ( frame.args[2] or '' ))
         return mispar_lotiot( (tonumber(frame.args[1]) or 0),  ( frame.args[2] or '' ))
    end,
   
    haba = haba,
    ['הבא'] = function( frame )
        local args = frame.args;
        if args[1] == nil then
            local parent = frame:getParent();
            args = parent.args;
        end
        return haba(args[1] or '')
    end,
   
    haqodem = haqodem,
    ['הקודם'] = function( frame )
        local args = frame.args;
        if args[1] == nil then
            local parent = frame:getParent();
            args = parent.args;
        end
        return haqodem(args[1] or '')
    end,
    ['שנה'] = function( frame )
        local args = frame.args;
        if args[1] == nil then
            local parent = frame:getParent();
            args = parent.args;
        end
        return gimatria(args[1] or '')*1000 + gimatria(args[2] or '')
     end,
     end,
}
}