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.


To show an example:


gives a result of


as expected. When I take


I get


which is not expected.

What I'd like is something like


and get


Is that possible using Span and Part?

  • 9
    $\begingroup$ Is J[mu, 1, 2, 3, 4, 5][[{1, 4, 5}]] acceptable? $\endgroup$
    – Kuba
    Commented Nov 15, 2018 at 22:15
  • 1
    $\begingroup$ 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. $\endgroup$
    – Brad
    Commented Nov 15, 2018 at 22:16
  • $\begingroup$ 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. $\endgroup$
    – Kuba
    Commented Nov 16, 2018 at 7:13


Browse other questions tagged or ask your own question.