GetPatternList ( RC ; nObj ; n )
List of decimal numbers whose binary form contains the same number of bits set to 1
Average rating: 4.4 (23 votes) Log in to vote
|Erich Schmidt - Show more from this author|
56¶52¶50¶49¶44¶42¶41¶38¶37¶35¶28¶26¶25¶22¶21¶19¶14¶13¶11¶7 [... with three bits set to 1]
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
The function returns a list of decimal values in descending order, whose binäry form has exactly n bits set to 1.
The list can be used to get all subsets with n elements from a character set with nObj elements.
Assumed it is TEXT="AXTVBC", the call
Let ( [ $MyList = GetPatternList("";Length(TEXT); 3) ] ; CustomList ( 1 ; ValueCount ( $MyList ) ; "Combine ( GetValue ( $MyList ; [n] ) ; TEXT )" ) )
returns a list containing all subsets from "AXTVBC" with 3 elements, so
Requires other CF: NextBinPattern()
Getting the right result requires a function call on the first recursion level with an empty RC-parm (RC="")
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.