Let me first apologize for not having a good example with my description and let me give you an example and a specific explanation of what I actually want to achieve:
In[403]:= g[x : {__} | __] := {x} // Flatten
p={{-1, -1, 1, 3/4}, {1, -1, -1, -(5/4)}, {-1, 1, -1, -(5/4)}, {0, 0, 0,
1}};
q={{-1, 0, 0, 0}, {0, -1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
r=Inverse[p];
g[p,q,r]
g[{p,q,r}]
Out[407]= {-1, -1, 1, 3/4, 1, -1, -1, -(5/4), -1, 1, -1, -(5/
4), 0, 0, 0, 1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -(
1/2), 0, -(1/2), -(1/4), -(1/2), -(1/2), 0, -(1/4), 0, -(1/2), -(1/
2), -(5/4), 0, 0, 0, 1}
Out[408]= {-1, -1, 1, 3/4, 1, -1, -1, -(5/4), -1, 1, -1, -(5/
4), 0, 0, 0, 1, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -(
1/2), 0, -(1/2), -(1/4), -(1/2), -(1/2), 0, -(1/4), 0, -(1/2), -(1/
2), -(5/4), 0, 0, 0, 1}
But actually, the output above is not what I wanted. What I really want is the following result:
In[409]:= {p,q,r}
Out[409]= {{{-1, -1, 1, 3/4}, {1, -1, -1, -(5/4)}, {-1,
1, -1, -(5/4)}, {0, 0, 0, 1}}, {{-1, 0, 0, 0}, {0, -1, 0, 0}, {0,
0, 1, 0}, {0, 0, 0, 1}}, {{-(1/2),
0, -(1/2), -(1/4)}, {-(1/2), -(1/2),
0, -(1/4)}, {0, -(1/2), -(1/2), -(5/4)}, {0, 0, 0, 1}}}
And based on my tries, it seems that the following method suggested by
Michael Rogers does the trick:
In[465]:= f1 // ClearAll;
f1[x_List] := x;
f1[args__] := Module[{elms},
elms=f1[{args}]
]
p={{-1, -1, 1, 3/4}, {1, -1, -1, -(5/4)}, {-1, 1, -1, -(5/4)}, {0, 0, 0,
1}};
q={{-1, 0, 0, 0}, {0, -1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};
r=Inverse[p];
f1[p,q,r]=={p,q,r}
f1[{p,q,r}]=={p,q,r}
Out[471]= True
Out[472]= True
However, I don't know if there is a more concise and compact implementation.
On the other hand, I also tried the following example:
f // ClearAll;
f[x_List] := x;
f[args__] := Module[{dim,elms},
elms=f[{args}];
dim=5;
{dim,elms}
]
args={{a},{b},{c}};
f[args]
f[args//Sequence]
f[{a},{b},{c}]
{{a}, {b}, {c}}
{{a}, {b}, {c}}
{5, {{a}, {b}, {c}}}
As you can see, the variable dim (5 in this example) is only returned in the last call. I am very confused about the logic of the code. Any hints will be appreciated.