View Single Post
04/01/15, 01:32 PM   #6
awesomebilly
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 23
Originally Posted by votan View Post
Confirmed.

Try to change
Code:
local function combinations(lst, n)
    local a, number, select, newlist
    newlist = {}
    number = #lst
    select = n
    a = {}
    for i = 1, select do
        a[#a + 1] = i
    end

    while (1) do
        local newrow = {}
        for i = 1, select do
            newrow[#newrow + 1] = lst[a[i]]
        end
        newlist[#newlist + 1] = newrow
        local i = select
        while (a[i] == (number - select + i)) do
            i = i - 1
        end
        if (i < 1) then break end
        a[i] = a[i] + 1
        for j = i, select do
            a[j] = a[i] + j - i
        end
    end
    return newlist
end
I'm headed home for lunch to try this. Oh my god if it works. TYVM.
I seen the global newthing = {} and changed that to local earlier, I can't believe I have a global 'i' that is so lame.

I'll report back after I update it.


TYVM again!
  Reply With Quote