Re: Get all combinations of n digits among m digits

new topic     » goto parent     » topic index » view thread      » older message » newer message
jmduro said...

Damned, there was still an error

LOL. I wonder if what you're actually missing is this:

function combinations(sequence s, integer lg) 
  combis = {}  
  if lg<=length(s) then 
    recurse(s, lg)  
  end if 
  return combis   
end function    

and then there should be no need to ever test nr=1.
Plus of course potentially skipping a whole pile of completely pointless effort.

PS: lg=0 currently returns {{}}, which I think is correct. There are probably pros and cons to making it return {} instead,

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu