I need to return an iterable list (that will be used in another steps) from an previous list that includes expandable content (variables and math operations).
\def \scale {1}
\pgfmathparse{\scale * 0.6}\edef\hc{\pgfmathresult}
%morphology coordinates x,y,..
\newcommand*{\xMorph}{0,0,0,0, 0, 0,0,0, \hc*0.5,-\hc*0.5,0,0,0, -\effdepth*0.5}
The approach that was used include an intermediate step for expand the list, but after the process the list isn´t iterable as is requested to it.
%expand aux func
\newcommand*{\expandlist}[1]{%
\edef\resultado{}
\foreach \i [remember=\i as \li (initially 0), evaluate=\i as \r using \i+\li]in {#1}{
\resultado{ \resultado \r}%
}
}
A simple test, like a for loop to obtain a single element one at time,
\begin{document}
%first case
\xMorph
%second case
\expandafter\def\expandafter\xLp\expandafter{\expandlist{\xMorph}}
\xLp
%third case
\foreach \k [count=\cn] in {\xLp}{\cn}
From the previus code, the results are: first one is the list without expansion (wrong), the second one is the list expanded but as a single element (1) as it shown in the count variable (\cn) derived from the for-loop.
0,0,0,0, 0, 0,0,0, 0.6*0.5,-0.6*0.5,0,0,0, -0.5*0.5 000000000.3-0.3000-0.25 1
any ideas will be well received.
\expandlistis not expandable, as it starts with\def. – egreg Sep 05 '18 at 20:07\foreach \k [count=\cn] in {4,5,6}{\cn}with a output:123– Rene Valenzuela Sep 05 '18 at 20:23\xdef\mylst{} \foreach \k [count=\cn] in {4,5,6}{\xdef\mylst{\mylst\cn}}. I guess there is more to the story, isn't it? – Sep 05 '18 at 20:43\cn. But the main goal is that i can make alist={a+b+c, d*0.5+4...}that cointains some algebraic expression inside and need to be "evaluate" (like \evaluate\list={} ... output: {1, 3.443, ....}) keeping the iterability before to pass to another function (foreach \i in {\list}{ \code}) . The final goal is obtain a list with variables and algebraic operations that can be modify. – Rene Valenzuela Sep 05 '18 at 21:12tikzmath. There you will be able to define recursive relations and so on, just look for "Fibonacci" in the pgfmanual. TikZ also allows you to build and parse arrays. – Sep 05 '18 at 21:23listofitemspackage for absorbing a list that can be regurgitated at will. If you were to put together a complete MWE, rather than just code snippets, I might be able to do something with it. – Steven B. Segletes Sep 24 '18 at 16:26