Module:Numeric interval

From Wikisphere
Jump to navigation Jump to search

Documentation for this module may be created at Module:Numeric interval/doc

local p = {}


function p.main(frame)

  
  local origArgs = (type(frame.getParent) == 'function') and frame:getParent().args or frame

  if(origArgs[1] == nil or origArgs[2] == nil) then
    return ''
  end


  local a  = tonumber(origArgs[1])
  local b  = tonumber(origArgs[2])

  if(a == nil or b == nil) then
    return ''
  end


  if(a < b) then
     increment = 1
  else
    increment = -1
  end


  map = {}   
  n = 1
  for i=a, b, increment do
    map[n] = i
    n = n + 1
  end


  local result = table.concat(map, ", ")

  mw.log('result')
  mw.log(result)
   
  return result

end
--=p.main({"10","22"})
return p