I have a function that generates output that is a list of linear combinations of symbols with numbers, as an example:
{e1, e2, 2 e11, (e12 - e21)/2, e12 + e21, 2 e22}
What I want to be able to do is to take this output and then produce the exact same linear combinations of nested list elements. The way that it works is that the length of the number in the symbol indicates which "level" of the list it comes from, and the number itself states which position in that list. For example, if
list = {{1, 2}, {{3, 2}, {4, 5}}}
then the output should be
{1, 2, 6, -1., 6, 10}
i.e.
{1, 2, 2*3, (2-4)/2, 2+4, 2*5}
It is quite easy to do it without the linear combinations, but with those included, I am a bit stuck as to how to proceed!
symb2idx[list_,symb_]:=Extract[list, #[
ToExpression@StringDrop[SymbolName[symb], 1]] & /@ {IntegerLength,
IntegerDigits} // Flatten]