LINUX.ORG.RU

История изменений

Исправление LINUX-ORG-RU, (текущая версия) :

local function range(str)
    local out = { }
    local qot = "'"
    for x,y in str:gmatch('(%w+)%.%.(%w+)') do
        local p = tonumber(x) and tonumber(y) and 1 or 0
        local a = tonumber(x) or x:byte()
        local b = tonumber(y) or y:byte()
        local s,e,n = a,b,1
        if a > b then a=b e=a n=-1 end
        for i=s,e,n do
            if p == 0 then
               out[#out+1]= qot..string.char(i)..qot
            else
               out[#out+1]= qot..i..qot
            end
        end
     end
     print(table.concat(out,','))
end
range("1..15")
range("A..P")
range("P..A")
range("15..1")
dron@gnu:~/Рабочий-стол$ lua x.lua 
'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15'
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P'
'P','O','N','M','L','K','J','I','H','G','F','E','D','C','B','A'
'15','14','13','12','11','10','9','8','7','6','5','4','3','2','1'

Тоже мне пригодится, тоже в профиле сохраню :D

Исходная версия LINUX-ORG-RU, :

local function range(str)
    local out = { }
    local qot = "'"
    for x,y in str:gmatch('(%w+)%.%.(%w+)') do
        local p = tonumber(x) and tonumber(y) and 1 or 0
        local a = tonumber(x) or x:byte()
        local b = tonumber(y) or y:byte()
        local s,e,n = a,b,1
        if a > b then a=b e=a n=-1 end
        for i=s,e,n do
            if p == 0 then
               out[#out+1]= qot..string.char(i)..qot
            else
               out[#out+1]= qot..i..qot
            end
        end
     end
     print(table.concat(out,','))
end
range("1..15")
range("A..P")
range("P..A")
range("15..1")
dron@gnu:~/Рабочий-стол$ lua x.lua 
'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15'
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P'
'P','O','N','M','L','K','J','I','H','G','F','E','D','C','B','A'
'15','14','13','12','11','10','9','8','7','6','5','4','3','2','1'