Is there some function in Mathematica which returns {c, i, j}
for an input c[i,j]
?
3 Answers
$\begingroup$
$\endgroup$
1
A simple approach is
c[i, j];
{Head[%], %1[[1]], %[[2]]}
(* {c, i, j} *)
Slightly more generally, use
f[x_] := Join[{Head[x]}, List @@ x]
f[c[i, j]]
(* {c, i, j} *)
-
1$\begingroup$
{Head[#], Sequence @@ #} &[c[i, j]]
also works. $\endgroup$ Commented Aug 19, 2016 at 19:39
$\begingroup$
$\endgroup$
$\begingroup$
$\endgroup$
using pattern-matching/deconstruction
c[i, j] /. a_[b_, c_] -> {a, b, c}
or define your own function:
f[a_[b_, c_]]:={a, b, c}
f[ c[i, j] ]
{c, i, j}