How to store a calculated value in array?
zz(1) = ( xx(1) + yy(1) )/2
\fpeval\zz(\counter){(\xx(\counter)+\yy(\counter))/2} NOT working
\documentclass{beamer}
\usepackage{siunitx,amsmath}
\usepackage{xparse,xfp}
\ExplSyntaxOn
\NewDocumentCommand{\newarray}{m}
{
\seq_new:c { l_hafid_array_#1_seq }
\cs_new:cpn { #1 } ##1
{
\seq_item:cn { l_hafid_array_#1_seq } { ##1 }
}
}
\NewDocumentCommand{\readarray}{mm}
{
\seq_set_split:cnn { l_hafid_array_#1_seq } { & } { #2 }
}
\cs_generate_variant:Nn \seq_set_split:Nnn { c }
\NewExpandableDocumentCommand{\sumarray}{O{15}m}
{
\fp_eval:n { round( \seq_use:cn { l_hafid_array_#2_seq } { + }, #1 ) }
}
\ExplSyntaxOff
\begin{document}
\newarray{xx}
\readarray{xx}{1&2&3&4&5}
\newarray{yy}
\readarray{yy}{6&7&8&9&10}
\begin{frame}
\begin{table}[]
\begin{tabular}{cccc}
No & xx & yy & zz \\ \hline
1 & \xx{1} & \yy{1} & \fpeval{(\xx{1}+\yy{1})/2} \\
2 & \xx{2} & \yy{2} & \fpeval{(\xx{2}+\yy{2})/2} \\
3 & \xx{3} & \yy{3} & \\
4 & \xx{4} & \yy{4} & \\
5 & \xx{5} & \yy{5} & \\ \hline
\end{tabular}
\end{table}
\end{frame}
%\newarray{zz}
%\readarray{xx}{0&0&0&0&0}
\newcount\counter
\counter=5
\loop
\fpeval\zz(\counter){(\xx(\counter)+\yy(\counter))/2}
\advance \counter by -1
\unless\ifnum \counter<1
\repeat
\end{document}



\xx(\counter)? It should be\xx{\counter}. But\fpevaldoes not assign values. – egreg Mar 22 '19 at 07:19