I have a List j={j[1],j[3],j[6]}. But this list is in fact a variable of my code, so i could have j={j[6],j[10]} either.
I need to define a function like this :
F[j[[1]]_,j[[2]]_,...,j[[n]]_]:=AFunction
So I wanted to do the following:
seqList=Sequence @@ j
F[seqList]:=AFunction
But the problem with that is seqList will not have the "_" after the variable. I would have a sequence that will look like j[[1]],j[[2]],... and NOT j[[1]]_, j[[2]]_
So how to define a sequence of parameters with the "_" after.
What is my actual goal :
I need to automatize a polynomial identification at the maximum.
I have a function that creates a polynomial with variable coefficient. This is :
CreerPoly[{j}, {degrees}]
For example if I want to create a polynome depending on x and y with degree 2 in aa and 1 in bb I will call CreerPoly[{aa,bb}, {2,1}]
And it will return me :
A[0, 0] + bb A[0, 1] + aa A[1, 0] + aa bb A[1, 1] + aa^2 A[2, 0] +
aa^2 bb A[2, 1]
I have a script that determines on how many variables my polynome will depends and at which degree.
And I need from this information to create the associated polynome.
But as I need to solve equations, I want that this polynome is a function of the variable I have found because I need to change the variables to solve the equations. For example if it depends on x,y,z I want to have a function : myFinalPolynome[x,y,z]. And of course as I said I don't know at the beginning how many variables I will have in my polynome.
j={j[1],j[3],j[6]}, this definition is recursive (you havejon the left and right sides of the assignment). Next, you have patterns named as list elements.j[[n]]_is not a valid pattern asj[[n]]cannot be used as a name for a pattern. What exactly did you want to achieve with this? I think, you're looking forBlankSequenceandBlankNullSequencewhich allow for variable number of arguments, but it's not clear, why you don't want to have the function take a (variable-length) list as its single argument. – LLlAMnYP Jun 20 '17 at 10:34@LLlAMnYPotherwise I don't see that you've replied. The first part of your question is really confusing, but I think I'm getting the gist of it finally. As I have asked already, what's wrong with defining your function for a general unknown-length sequence of variables? E.g.f[x__] := Times[x]; f[2,3]->6, f[1]->1, f[4,3,5]->60or for a list, likef[x_List] := Sum[2i, {i, x}]; f[{1,4,5}]->10– LLlAMnYP Jun 20 '17 at 10:4520. facepalm – LLlAMnYP Jun 20 '17 at 10:53