Function Reference


Returns an array of the combinations of a set of elements from a selected 1D array

#include <Array.au3>
_ArrayCombinations ( Const ByRef $aArray, $iSet [, $sDelimiter = ""] )


$aArray The Array to use
$iSet Size of the combinations set
$sDelimiter [optional] String result separator, default is "" for none

Return Value

Success: an array of Combinations
The first element ($aArray[0]) contains the number of strings returned.
The remaining elements ($aArray[1], $aArray[2], etc.) contain the Combinations.
Failure: sets the @error flag to non-zero.
@error: 1 - The Input Must be an Array
2 - $aArray is not a 1D array


The input array must be 0-based, i.e. no counter in $aArray[0]. Based on an algorithm by Kenneth H. Rosen.




; Declare a 1-dimensional array, and create an array showing the Possible Combinations

#include <Array.au3>

Local $aArray[5] = [1, 2, 3, 4, 5]

For $i = 1 To UBound($aArray)
    Local $aArrayCombo = _ArrayCombinations($aArray, $i, ",")
    _ArrayDisplay($aArrayCombo, "iSet = " & $i)