Speed

Beat Cornaz B.Cornaz at gmx.net
Tue Aug 26 09:42:37 EDT 2014


Works like a charm, Geoff. Great way of tackling the thing, very original.

function P2 N,B
  -- N is the depth to permute
  -- B is the ASCII value to start from
  -- so P2(1,49) returns 21 cr 12
  -- P2(2,53) returns 675 cr 765 cr 756 cr 576 cr 657 cr 567
  if N = 0 then return numToChar(B) & cr
  put P2(N - 1,B) into T
  add B to N
  repeat with i = B to N - 1
     put T into T2
     replace numToChar(i) with numToChar(N) in T2
     replace cr with numToChar(i) & cr in T2
     put T2 after R
  end repeat
  replace cr with numToChar(N) & cr in T
  return R & T
end P2

If I input  B =97 I get the permutations in abcd etc. which I often use, so really great
If I input  B= 48 I get  the permutations in numbers 01234 etc. which I also often use.
Beyond 9 I can easily make items and replace the ascii chars with 10, 11 etc.

The DUPLICATES :
I've been working on it to try to include this functionality into your script, but no dice yet. It is not really obvious at first sight.
I'll continue to work on it though. If you or anyone has a bright idea, I'd love to hear it.

I must say that I am really charmed by this solution of Geoff, it's something I'd never would have thought of. Hats off !

Cheers, Beat



More information about the use-livecode mailing list