In this answer, u/Qrrbrbirlbel has written a wonderful code for a command that makes long exact sequences simply by taking what are the entries. To understand and get a feel for its objective, I suggest visiting the answer once; but to put it simply, the objective was to make a command \longexactsequence{-,-,...,-} that made a long sequence with the objects in the order separated by commas.
I modified the code presented to make it a bit more flexible (the zeros at the start and end were a bit restrictive):
\usepackage{extarrows,pgffor}
\newcommand*{\longexactsequence}[2]{%
\foreach \superscript/\entry in {#1} {%
\entry \xlongrightarrow{\ifx\superscript\entry\else\superscript\fi}%
} #2%
}
This code works exactly the same way the previous one did, except that to write a long sequence that connects A,B,C,D,E, you use:
\longexact{A,B,C,D}{E}
This works wonderfully; it has all the functions the earlier code had (in particular naming functions). But one can see where it falls from being perfect: you have to write the last object in the sequence in a separate bracket.
I would highly appreciate some help with fixing this bit; is there a way to make the command such that you only need one parentheses, without losing all the accessibility (particularly, the arrow labelling) the command already has? I believe something could be done if there was a way to identify the last entry in the input.
I would prefer an answer that does not create a new bit of code, but rather modifies the code already polished and presented, but any answer is welcome!

