Function Reference


_ArrayPermute

Returns an array of the Permutations of all Elements in a 1D array

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

Parameters

$aArray The Array to get Permutations
$sDelimiter [optional] String result separator, default is "" for none

Return Value

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

Remarks

The input array must be 0-based, i.e. no counter in $aArray[0].
Based on the algorithm by Alexander Bogomolny (http://www.bearcave.com/random_hacks/permute.html).

Related

_ArrayCombinations

Example

; Declare a 1-dimensional array, return an Array of permutations

#include <Array.au3>

Local $aArray[4] = [1, 2, 3, 4]
Local $aNewArray = _ArrayPermute($aArray, ",") ;Using Default Parameters
_ArrayDisplay($aNewArray, "Array Permuted")