0
$\begingroup$

I often have a number for which I want to remove its head, e.g. {1}. I know of two ways to remove the head:

{1}[[1]]
# & @@ {1}

Neither of these methods seem particularly transparent to me. What is the "right" way to do this common transformation?

$\endgroup$
3
  • 2
    $\begingroup$ I would do ## & @@ # &, so the same what you've done but more general, your way fails for {1, 2}. $\endgroup$
    – Kuba
    Commented May 9, 2015 at 18:26
  • 2
    $\begingroup$ Or with pattern matching: expr /. _[x__] :> x $\endgroup$ Commented May 9, 2015 at 18:31
  • 2
    $\begingroup$ Identity @@ {1} or Sequence @@ {1} depending on what you want to achieve... but the others seems transparent enough, too. $\endgroup$
    – Yves Klett
    Commented May 9, 2015 at 18:36

0