1
$\begingroup$

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?

$\endgroup$

closed as off-topic by Kuba Nov 16 '18 at 7:13

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Kuba
If this question can be reworded to fit the rules in the help center, please edit the question.

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