Actionscript 3.0 algorithm for generating combinations from n numbers in a list

I recently had to create an application that would take a list of words in an xml document and generate a unique combination of each of those words. The spread for the set of combinations was 1 to 4. Thus for a list 1,2,3,4 the generated list had to be:

11,21,2,31,2,3,422,12,1,3and so on...It was one of those days when I truly wished I had stuck to my Maths. Anyroad it was back to the grindstone to find a solution for this little pickle. This is the general idea of the solution.You begin by extraction the data from the XML and having it in an array. Next you nest 4 'for (var i:int = )' loops, for each subsequent loop the initial count parameter is set to a +1 increment of the previous loop initial count. In the first loop you add the first item in the array to the end of the array.var c:int = 0 for (var i:int = c; i < _list.length-3; i++) { _displaylist.push( _list[i] ) var b:int = i +1;

The idea being that as you loop through you set up the array so thateach item in the array has a chance at being the first item in theloop. Having set up the loop you set up a counter which increments every time the combination algorithm is run till you get to the end of the initial array. This counter sets up a recursion of the algorithm till the end of the intial list is reached. This counter sets the value for 'c'.