I have the following issue with some recursive calculus.
I just write the function \recsum that recursively computes the sum of an unspecified amount of integers.
It works when I call the function by itself. But when I try to store the results, it doesn't work anymore. Error:
! Incomplete \iffalse; all text was ignored after line 22.
\fi</p>
I try printing \expandafter\meaning\mysum{12345}, but it only makes me even more bewildered...
Here is the code I wrote:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\def\recsum#1#2#3\endsum{%
\pgfmathsetmacro{\ble}{#1+#2}%
\def\dum{#3}%
\ifx\dum\empty%
\ble%
\else%
\recsum{\ble}#3\endsum%
\fi%
}
\def\mysum#1{\recsum{0}#1\endsum}
-- \mysum{14283} --
% % This doesn't work:
% \edef\ble{\mysum{14283}}
\end{document}
What's happening here?

\mysumhave an optional argument that, if present, receives the result at the end of the calculation. More or less as thexstringpackage does. – Phelype Oleinik May 18 '18 at 12:57\edef– David Carlisle May 18 '18 at 13:02\mysumand\recsumseems to work fine. I'll try to see later if it solves all my problems (the real function is a bit more complicated)! Thanks! :D – Vinzza May 18 '18 at 13:25