I often get List
s that contain a single item, like {name}
or {{2,3,4}}
.
Is there a function that simply takes the item out of the List
without needing to use Part
, like #[[1]]&
?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI often get List
s that contain a single item, like {name}
or {{2,3,4}}
.
Is there a function that simply takes the item out of the List
without needing to use Part
, like #[[1]]&
?
You can use First
as in First@{{2,3,4}}
. Not entirely sure though, why this should be preferable to [[1]]
.
a[[1]] // FullForm
. $\endgroup$First
...Last
... $\endgroup$Part
? It's a basic and very fast function. $\endgroup$