[Originally posted by TeeGee]

I'v been programming in VB for seven days now and came to a problem. I need to find a better function for permutating. it's called with elements in range 2-10 and run the testp(blah) function for every permutation.. you got a faster
idea??


Public Function permc(ByRef elements As Byte, perms() As Byte)
ÿ ÿ
ÿ ÿ If elements = 2 Then
ÿ ÿ ÿ ÿ ÿ ÿ Call testp(perms())
ÿ ÿ ÿ ÿ table(0) = table(1) 'index 0 is just
ÿ ÿ ÿ ÿ table(1) = table(2) 'for swiching
ÿ ÿ ÿ ÿ table(2) = table(0) 'elements
ÿ ÿ ÿ ÿ ÿ ÿ Call testp(perms())
ÿ ÿ ÿ ÿ table(0) = table(1)
ÿ ÿ ÿ ÿ table(1) = table(2)
ÿ ÿ ÿ ÿ table(2) = table(0)
ÿ ÿ Else
ÿ ÿ ÿ ÿ For Counter = 1 To elements
ÿ ÿ ÿ ÿ ÿ ÿ table(0) = perms(elements)
ÿ ÿ ÿ ÿ ÿ ÿ table(elements) = table(Counter)
ÿ ÿ ÿ ÿ ÿ ÿ table(Counter) = table(0)
ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ Call permc(elements - 1,perms())
ÿ ÿ ÿ ÿ ÿ ÿ table(0) = table(elements)
ÿ ÿ ÿ ÿ ÿ ÿ table(elements) = table(Counter)
ÿ ÿ ÿ ÿ ÿ ÿ table(Counter) = table(0)
ÿ ÿ ÿ ÿ Next
ÿ ÿ End If
end function