function like Mathematica's Tuples



El mar, 18-05-2010 a las 15:33 +0200, pslomski escribi?:
> Hello.
> 
> In Mathematica there is a Tuples function:
> "Tuples[list, n] - generates a list of all possible n-tuples of elements from list."
> e.g. all possible 2-tuples of 0 and 1:
> In[1]:= Tuples[{0, 1}, 2] 
> Out[1]= {{0,0}, {0,1}, {1, 0}, {1,1}}
> 
> In Maxima I use create_list function like this:
> (%i1) create_list([x1, x2], x1, [0,1], x2, [0, 1]);
> (%o1) [[0,0],[0,1],[1,0],[1,1]]
> 
> but it's for fixed dimension N=2. For N=3,4,5,... I need to extend expression (%i1) manually.
> Is there any "built-in" way to do it like in Mathematica or maybe I have to write custom function to do it?
> 

? cartesian_product

--
Mario