In my attempts to get grasp on expl3
I have come into a wall, I cannot figure out how store the result of a function.
For example in pseudocode of what I want to do is this, store the second character of tempstring
(that is the character b
) in otherstring
without changing tempstring
string tempstring = abcde
string otherstring = tempstring[2]
print tempstring
print otherstring
This would result in the output of abcde b
In the following expl3
code I believe I have declared my variables correctly, but the 4th line where I do my operation does not work.
\tl_new:N \templist
\tl_new:N \otherlist
\tl_set:Nn \templist {abcde}
\tl_set:Nn \otherlist {\tl_item:Nn \templist {2}}
\templist
\otherlist
I would have expected this to output abcde b
as well but it does not.
And unfortunately \otherlist = \templist
doesn't seem to do what I need either.
I have also tried \tl_set_eq:Nn \otherlist {\tl_item:Nn \templist {2}}
but that doesn't work either.
I have edited the code to show a minimal broken example, apparently what I wrote above works just fine.
Edited again, I found my error. David was correct. In my main code I had forgotten the :Nn
after \tl_item
\tl_set:Nx \otherlist {\tl_item:Nn \templist {2}}
.expl3
context use~
as in\templist ~ \otherlist
.