# Selecting the 1st and then subsequent elements in an expression [closed]

I'm using a mixture of Span and Part to try and extract the arguments of a function that I need.

I'm using a function such as $$J^\mu(1,2,3)$$ and I'll be trying to represent this as J[mu,Range[1,3]]or more generally for any index or any number of arguments, J[index_,Range[1,n_]].

I'll need to select the first element, i.e the index of this function every time, and then I'll need to select a few consecutive elements of the list. I.e; I'll need to select terms such as J[index,2,3].

I've tried using some variations of Span inside the Partargument, but I'm struggling to solely take the first variable, plus some extras.

Particularly, I'm trying to program the Berends-Giele recursion relation for n-gluons.

Any help would be much appreciated.

### Edit

To show an example:

J[mu,1,2,3,4,5][[3;;5]]


gives a result of

J[2,3,4]


as expected. When I take

J[mu,1,2,3,4,5][[1]]


I get

mu


which is not expected.

What I'd like is something like

J[mu,1,2,3,4,5][[1,3;;4]]


and get

J[mu,3,4]


Is that possible using Span and Part?

• Is J[mu, 1, 2, 3, 4, 5][[{1, 4, 5}]] acceptable?
– Kuba
Commented Nov 15, 2018 at 22:15
• That's exactly what I wanted. Thank you very much! If I can accept that as an answer to help you then I'll happily do so. I don't know why I didn't try that first correctly. Much appreciate Kuba.
• Since this is part of ref / Part / Generalizations and extensions let me know as mark it as easy to find in documentation. Don't get me wrong, I know it is easy to miss things in such a big system but still, it is there in a place that is somewhat expected to address it.