Skip to content

Commit

Permalink
Fix permutations (we were not using them all correctly).
Browse files Browse the repository at this point in the history
  • Loading branch information
hadronized committed Feb 7, 2021
1 parent 4d9fce0 commit 41e89e7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lua/vroom/perm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ end
local function next_perm(term_keys, seq_keys, perm)
local perm_len = #perm

if perm_len == 0 then
return { first_key(term_keys) }
end

-- try to increment the terminal key; if it’s possible, then we can directly return the permutation as it’s the next
-- one
local term_key = next_key(term_keys, perm[perm_len])
Expand Down Expand Up @@ -88,7 +92,7 @@ function M.permutations(keys, n, opts)
local term_keys = keys:sub(1, quarter)
local seq_keys = keys:sub(quarter + 1)
local perms = {}
local perm = { keys:sub(1, 1) }
local perm = {}

for _ = 1, n do
perm = next_perm(term_keys, seq_keys, perm)
Expand Down

0 comments on commit 41e89e7

Please sign in to comment.