Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Every combination of a list of choices
Message
De
08/05/2007 12:16:34
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01223417
Message ID:
01223450
Vues:
15
Something like this:
Close Databases All
Create Cursor retvalues (retvalue C(20))
nMaxLevels=5
=genpermuts(1,'')
SELECT retvalues
browse
Return

FUNCTION genpermuts
LPARAMETERS nLevel,cPrevvalue
LOCAL nloop,cAddvalue
FOR nLoop=1 TO nMaxLevels
	cAddvalue=Transform(nLoop)
	IF AT(cAddvalue,cPrevvalue)>0
		loop
	endif
	cRetvalue=cPrevvalue+cAddvalue
	If nLevel=nMaxLevels
		Insert Into retvalues values(cRetvalue)
	else
		=genpermuts(nLevel+1,cRetvalue)
	Endif
ENDFOR
Most likely, you will enumerate your orders, firstly, i.e. 1,2,3... and then use this code.

>Hi Edward
>
>That's it, I want all permutations excluding repeating values.
>
>>>Hi!
>>>
>>>Say I've got a list of calls I want to make in a day.
>>>
>>>Say I have ten calls, I want to work out every combination of order of visits.
>>>
>>>Has anyone any ideas on how I would achieve this?
>>>
>>>Any help extremley appreciated
>>
>>Do you want to generate all permutations of N values, except repeating values? (i.e. 12345, 54321, but not 12134).
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform