How to store values in an array?












2
















How to store a calculated value in array?




zz(1) = ( xx(1) + yy(1) )/2




fpevalzz(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}
newcountcounter
counter=5
loop
fpevalzz(counter){(xx(counter)+yy(counter))/2}
advance counter by -1
unlessifnum counter<1
repeat

end{document}









share|improve this question



























    2
















    How to store a calculated value in array?




    zz(1) = ( xx(1) + yy(1) )/2




    fpevalzz(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}
    newcountcounter
    counter=5
    loop
    fpevalzz(counter){(xx(counter)+yy(counter))/2}
    advance counter by -1
    unlessifnum counter<1
    repeat

    end{document}









    share|improve this question

























      2












      2








      2









      How to store a calculated value in array?




      zz(1) = ( xx(1) + yy(1) )/2




      fpevalzz(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}
      newcountcounter
      counter=5
      loop
      fpevalzz(counter){(xx(counter)+yy(counter))/2}
      advance counter by -1
      unlessifnum counter<1
      repeat

      end{document}









      share|improve this question















      How to store a calculated value in array?




      zz(1) = ( xx(1) + yy(1) )/2




      fpevalzz(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}
      newcountcounter
      counter=5
      loop
      fpevalzz(counter){(xx(counter)+yy(counter))/2}
      advance counter by -1
      unlessifnum counter<1
      repeat

      end{document}






      fp






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      sandusandu

      3,68942856




      3,68942856






















          2 Answers
          2






          active

          oldest

          votes


















          1














          I did not really try to make your example work but would like to propose an alternative way of doing what I think you want to do.



          documentclass{beamer}
          usepackage{pgfmath}

          begin{document}

          defxx{{1,2,3,4,5}}
          defyy{{6,7,8,9,10}}

          newcommand{Parse}[1]{pgfmathparse{#1}pgfmathresult}

          begin{frame}
          begin{table}
          begin{tabular}{cccc}
          No & xx & yy & zz \ hline
          1 & Parse{xx[0]} & Parse{yy[0]} & Parse{xx[0]/2+yy[0]/2}\
          2 & Parse{xx[1]} & Parse{yy[1]} & Parse{xx[1]/2+yy[1]/2}\
          3 & Parse{xx[2]} & Parse{yy[2]} & Parse{xx[2]/2+yy[2]/2}\
          4 & Parse{xx[3]} & Parse{yy[3]} & Parse{xx[3]/2+yy[3]/2}\
          5 & Parse{xx[4]} & Parse{yy[4]} & Parse{xx[4]/2+yy[4]/2}\
          hline
          end{tabular}
          end{table}

          newcounter{counter}
          setcounter{counter}{4}
          loop
          Parse{xx[numbervalue{counter}]/2+yy[numbervalue{counter}]/2}
          addtocounter{counter}{-1}
          unlessifnumnumbervalue{counter}=-1
          repeat
          end{frame}
          end{document}


          enter image description here



          Of course you can also store the results in an array. (Note that I am using foreach here which I find easier to deal with.



          documentclass{beamer}
          usepackage{pgfmath,pgffor}

          begin{document}

          defxx{{1,2,3,4,5}}
          defyy{{6,7,8,9,10}}

          newcommand{Parse}[1]{pgfmathparse{#1}pgfmathresult}

          begin{frame}
          begin{table}
          begin{tabular}{cccc}
          No & xx & yy & zz \ hline
          1 & Parse{xx[0]} & Parse{yy[0]} & Parse{xx[0]/2+yy[0]/2}\
          2 & Parse{xx[1]} & Parse{yy[1]} & Parse{xx[1]/2+yy[1]/2}\
          3 & Parse{xx[2]} & Parse{yy[2]} & Parse{xx[2]/2+yy[2]/2}\
          4 & Parse{xx[3]} & Parse{yy[3]} & Parse{xx[3]/2+yy[3]/2}\
          5 & Parse{xx[4]} & Parse{yy[4]} & Parse{xx[4]/2+yy[4]/2}\
          hline
          end{tabular}
          end{table}

          foreach X in {4,3,...,0}
          {%
          pgfmathparse{xx[X]/2+yy[X]/2}
          ifnumX=4
          xdefzz{pgfmathresult}
          else
          xdefzz{zz,pgfmathresult}
          fi
          }
          xdefzz{{zz}}
          Parse{zz[2]}
          end{frame}
          end{document}





          share|improve this answer


























          • is it possible to store in zz(1), zz(2) etc...

            – sandu
            1 hour ago











          • @sandu Yes. I added an example that builds up a list zz and prints one of its elements.

            – marmot
            1 hour ago



















          1














          The listofitems package may give you at least some of what you need in terms of storing arrays.



          documentclass{beamer}
          usepackage{siunitx,amsmath,xparse,xfp}
          usepackage{listofitems}
          begin{document}
          setsepchar{&}
          readlistxx{1&2&3&4&5}
          readlistyy{6&7&8&9&10}
          begin{frame}[fragile]
          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}
          makeatletter
          deftmp{}
          foreachitemzinxx{%
          ifnumzcnt=1relaxelseg@addto@macrotmp{&}fi%
          edeftmpA{fpeval{(z+yy[zcnt])/2}}%
          expandafterg@addto@macroexpandaftertmpexpandafter{tmpA}}
          makeatother
          readlistzz{tmp}
          foreachitemzinzz{zz[-zcnt] }
          end{frame}
          end{document}


          enter image description here






          share|improve this answer

























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "85"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480828%2fhow-to-store-values-in-an-array%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            I did not really try to make your example work but would like to propose an alternative way of doing what I think you want to do.



            documentclass{beamer}
            usepackage{pgfmath}

            begin{document}

            defxx{{1,2,3,4,5}}
            defyy{{6,7,8,9,10}}

            newcommand{Parse}[1]{pgfmathparse{#1}pgfmathresult}

            begin{frame}
            begin{table}
            begin{tabular}{cccc}
            No & xx & yy & zz \ hline
            1 & Parse{xx[0]} & Parse{yy[0]} & Parse{xx[0]/2+yy[0]/2}\
            2 & Parse{xx[1]} & Parse{yy[1]} & Parse{xx[1]/2+yy[1]/2}\
            3 & Parse{xx[2]} & Parse{yy[2]} & Parse{xx[2]/2+yy[2]/2}\
            4 & Parse{xx[3]} & Parse{yy[3]} & Parse{xx[3]/2+yy[3]/2}\
            5 & Parse{xx[4]} & Parse{yy[4]} & Parse{xx[4]/2+yy[4]/2}\
            hline
            end{tabular}
            end{table}

            newcounter{counter}
            setcounter{counter}{4}
            loop
            Parse{xx[numbervalue{counter}]/2+yy[numbervalue{counter}]/2}
            addtocounter{counter}{-1}
            unlessifnumnumbervalue{counter}=-1
            repeat
            end{frame}
            end{document}


            enter image description here



            Of course you can also store the results in an array. (Note that I am using foreach here which I find easier to deal with.



            documentclass{beamer}
            usepackage{pgfmath,pgffor}

            begin{document}

            defxx{{1,2,3,4,5}}
            defyy{{6,7,8,9,10}}

            newcommand{Parse}[1]{pgfmathparse{#1}pgfmathresult}

            begin{frame}
            begin{table}
            begin{tabular}{cccc}
            No & xx & yy & zz \ hline
            1 & Parse{xx[0]} & Parse{yy[0]} & Parse{xx[0]/2+yy[0]/2}\
            2 & Parse{xx[1]} & Parse{yy[1]} & Parse{xx[1]/2+yy[1]/2}\
            3 & Parse{xx[2]} & Parse{yy[2]} & Parse{xx[2]/2+yy[2]/2}\
            4 & Parse{xx[3]} & Parse{yy[3]} & Parse{xx[3]/2+yy[3]/2}\
            5 & Parse{xx[4]} & Parse{yy[4]} & Parse{xx[4]/2+yy[4]/2}\
            hline
            end{tabular}
            end{table}

            foreach X in {4,3,...,0}
            {%
            pgfmathparse{xx[X]/2+yy[X]/2}
            ifnumX=4
            xdefzz{pgfmathresult}
            else
            xdefzz{zz,pgfmathresult}
            fi
            }
            xdefzz{{zz}}
            Parse{zz[2]}
            end{frame}
            end{document}





            share|improve this answer


























            • is it possible to store in zz(1), zz(2) etc...

              – sandu
              1 hour ago











            • @sandu Yes. I added an example that builds up a list zz and prints one of its elements.

              – marmot
              1 hour ago
















            1














            I did not really try to make your example work but would like to propose an alternative way of doing what I think you want to do.



            documentclass{beamer}
            usepackage{pgfmath}

            begin{document}

            defxx{{1,2,3,4,5}}
            defyy{{6,7,8,9,10}}

            newcommand{Parse}[1]{pgfmathparse{#1}pgfmathresult}

            begin{frame}
            begin{table}
            begin{tabular}{cccc}
            No & xx & yy & zz \ hline
            1 & Parse{xx[0]} & Parse{yy[0]} & Parse{xx[0]/2+yy[0]/2}\
            2 & Parse{xx[1]} & Parse{yy[1]} & Parse{xx[1]/2+yy[1]/2}\
            3 & Parse{xx[2]} & Parse{yy[2]} & Parse{xx[2]/2+yy[2]/2}\
            4 & Parse{xx[3]} & Parse{yy[3]} & Parse{xx[3]/2+yy[3]/2}\
            5 & Parse{xx[4]} & Parse{yy[4]} & Parse{xx[4]/2+yy[4]/2}\
            hline
            end{tabular}
            end{table}

            newcounter{counter}
            setcounter{counter}{4}
            loop
            Parse{xx[numbervalue{counter}]/2+yy[numbervalue{counter}]/2}
            addtocounter{counter}{-1}
            unlessifnumnumbervalue{counter}=-1
            repeat
            end{frame}
            end{document}


            enter image description here



            Of course you can also store the results in an array. (Note that I am using foreach here which I find easier to deal with.



            documentclass{beamer}
            usepackage{pgfmath,pgffor}

            begin{document}

            defxx{{1,2,3,4,5}}
            defyy{{6,7,8,9,10}}

            newcommand{Parse}[1]{pgfmathparse{#1}pgfmathresult}

            begin{frame}
            begin{table}
            begin{tabular}{cccc}
            No & xx & yy & zz \ hline
            1 & Parse{xx[0]} & Parse{yy[0]} & Parse{xx[0]/2+yy[0]/2}\
            2 & Parse{xx[1]} & Parse{yy[1]} & Parse{xx[1]/2+yy[1]/2}\
            3 & Parse{xx[2]} & Parse{yy[2]} & Parse{xx[2]/2+yy[2]/2}\
            4 & Parse{xx[3]} & Parse{yy[3]} & Parse{xx[3]/2+yy[3]/2}\
            5 & Parse{xx[4]} & Parse{yy[4]} & Parse{xx[4]/2+yy[4]/2}\
            hline
            end{tabular}
            end{table}

            foreach X in {4,3,...,0}
            {%
            pgfmathparse{xx[X]/2+yy[X]/2}
            ifnumX=4
            xdefzz{pgfmathresult}
            else
            xdefzz{zz,pgfmathresult}
            fi
            }
            xdefzz{{zz}}
            Parse{zz[2]}
            end{frame}
            end{document}





            share|improve this answer


























            • is it possible to store in zz(1), zz(2) etc...

              – sandu
              1 hour ago











            • @sandu Yes. I added an example that builds up a list zz and prints one of its elements.

              – marmot
              1 hour ago














            1












            1








            1







            I did not really try to make your example work but would like to propose an alternative way of doing what I think you want to do.



            documentclass{beamer}
            usepackage{pgfmath}

            begin{document}

            defxx{{1,2,3,4,5}}
            defyy{{6,7,8,9,10}}

            newcommand{Parse}[1]{pgfmathparse{#1}pgfmathresult}

            begin{frame}
            begin{table}
            begin{tabular}{cccc}
            No & xx & yy & zz \ hline
            1 & Parse{xx[0]} & Parse{yy[0]} & Parse{xx[0]/2+yy[0]/2}\
            2 & Parse{xx[1]} & Parse{yy[1]} & Parse{xx[1]/2+yy[1]/2}\
            3 & Parse{xx[2]} & Parse{yy[2]} & Parse{xx[2]/2+yy[2]/2}\
            4 & Parse{xx[3]} & Parse{yy[3]} & Parse{xx[3]/2+yy[3]/2}\
            5 & Parse{xx[4]} & Parse{yy[4]} & Parse{xx[4]/2+yy[4]/2}\
            hline
            end{tabular}
            end{table}

            newcounter{counter}
            setcounter{counter}{4}
            loop
            Parse{xx[numbervalue{counter}]/2+yy[numbervalue{counter}]/2}
            addtocounter{counter}{-1}
            unlessifnumnumbervalue{counter}=-1
            repeat
            end{frame}
            end{document}


            enter image description here



            Of course you can also store the results in an array. (Note that I am using foreach here which I find easier to deal with.



            documentclass{beamer}
            usepackage{pgfmath,pgffor}

            begin{document}

            defxx{{1,2,3,4,5}}
            defyy{{6,7,8,9,10}}

            newcommand{Parse}[1]{pgfmathparse{#1}pgfmathresult}

            begin{frame}
            begin{table}
            begin{tabular}{cccc}
            No & xx & yy & zz \ hline
            1 & Parse{xx[0]} & Parse{yy[0]} & Parse{xx[0]/2+yy[0]/2}\
            2 & Parse{xx[1]} & Parse{yy[1]} & Parse{xx[1]/2+yy[1]/2}\
            3 & Parse{xx[2]} & Parse{yy[2]} & Parse{xx[2]/2+yy[2]/2}\
            4 & Parse{xx[3]} & Parse{yy[3]} & Parse{xx[3]/2+yy[3]/2}\
            5 & Parse{xx[4]} & Parse{yy[4]} & Parse{xx[4]/2+yy[4]/2}\
            hline
            end{tabular}
            end{table}

            foreach X in {4,3,...,0}
            {%
            pgfmathparse{xx[X]/2+yy[X]/2}
            ifnumX=4
            xdefzz{pgfmathresult}
            else
            xdefzz{zz,pgfmathresult}
            fi
            }
            xdefzz{{zz}}
            Parse{zz[2]}
            end{frame}
            end{document}





            share|improve this answer















            I did not really try to make your example work but would like to propose an alternative way of doing what I think you want to do.



            documentclass{beamer}
            usepackage{pgfmath}

            begin{document}

            defxx{{1,2,3,4,5}}
            defyy{{6,7,8,9,10}}

            newcommand{Parse}[1]{pgfmathparse{#1}pgfmathresult}

            begin{frame}
            begin{table}
            begin{tabular}{cccc}
            No & xx & yy & zz \ hline
            1 & Parse{xx[0]} & Parse{yy[0]} & Parse{xx[0]/2+yy[0]/2}\
            2 & Parse{xx[1]} & Parse{yy[1]} & Parse{xx[1]/2+yy[1]/2}\
            3 & Parse{xx[2]} & Parse{yy[2]} & Parse{xx[2]/2+yy[2]/2}\
            4 & Parse{xx[3]} & Parse{yy[3]} & Parse{xx[3]/2+yy[3]/2}\
            5 & Parse{xx[4]} & Parse{yy[4]} & Parse{xx[4]/2+yy[4]/2}\
            hline
            end{tabular}
            end{table}

            newcounter{counter}
            setcounter{counter}{4}
            loop
            Parse{xx[numbervalue{counter}]/2+yy[numbervalue{counter}]/2}
            addtocounter{counter}{-1}
            unlessifnumnumbervalue{counter}=-1
            repeat
            end{frame}
            end{document}


            enter image description here



            Of course you can also store the results in an array. (Note that I am using foreach here which I find easier to deal with.



            documentclass{beamer}
            usepackage{pgfmath,pgffor}

            begin{document}

            defxx{{1,2,3,4,5}}
            defyy{{6,7,8,9,10}}

            newcommand{Parse}[1]{pgfmathparse{#1}pgfmathresult}

            begin{frame}
            begin{table}
            begin{tabular}{cccc}
            No & xx & yy & zz \ hline
            1 & Parse{xx[0]} & Parse{yy[0]} & Parse{xx[0]/2+yy[0]/2}\
            2 & Parse{xx[1]} & Parse{yy[1]} & Parse{xx[1]/2+yy[1]/2}\
            3 & Parse{xx[2]} & Parse{yy[2]} & Parse{xx[2]/2+yy[2]/2}\
            4 & Parse{xx[3]} & Parse{yy[3]} & Parse{xx[3]/2+yy[3]/2}\
            5 & Parse{xx[4]} & Parse{yy[4]} & Parse{xx[4]/2+yy[4]/2}\
            hline
            end{tabular}
            end{table}

            foreach X in {4,3,...,0}
            {%
            pgfmathparse{xx[X]/2+yy[X]/2}
            ifnumX=4
            xdefzz{pgfmathresult}
            else
            xdefzz{zz,pgfmathresult}
            fi
            }
            xdefzz{{zz}}
            Parse{zz[2]}
            end{frame}
            end{document}






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 1 hour ago

























            answered 1 hour ago









            marmotmarmot

            110k5137256




            110k5137256













            • is it possible to store in zz(1), zz(2) etc...

              – sandu
              1 hour ago











            • @sandu Yes. I added an example that builds up a list zz and prints one of its elements.

              – marmot
              1 hour ago



















            • is it possible to store in zz(1), zz(2) etc...

              – sandu
              1 hour ago











            • @sandu Yes. I added an example that builds up a list zz and prints one of its elements.

              – marmot
              1 hour ago

















            is it possible to store in zz(1), zz(2) etc...

            – sandu
            1 hour ago





            is it possible to store in zz(1), zz(2) etc...

            – sandu
            1 hour ago













            @sandu Yes. I added an example that builds up a list zz and prints one of its elements.

            – marmot
            1 hour ago





            @sandu Yes. I added an example that builds up a list zz and prints one of its elements.

            – marmot
            1 hour ago











            1














            The listofitems package may give you at least some of what you need in terms of storing arrays.



            documentclass{beamer}
            usepackage{siunitx,amsmath,xparse,xfp}
            usepackage{listofitems}
            begin{document}
            setsepchar{&}
            readlistxx{1&2&3&4&5}
            readlistyy{6&7&8&9&10}
            begin{frame}[fragile]
            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}
            makeatletter
            deftmp{}
            foreachitemzinxx{%
            ifnumzcnt=1relaxelseg@addto@macrotmp{&}fi%
            edeftmpA{fpeval{(z+yy[zcnt])/2}}%
            expandafterg@addto@macroexpandaftertmpexpandafter{tmpA}}
            makeatother
            readlistzz{tmp}
            foreachitemzinzz{zz[-zcnt] }
            end{frame}
            end{document}


            enter image description here






            share|improve this answer






























              1














              The listofitems package may give you at least some of what you need in terms of storing arrays.



              documentclass{beamer}
              usepackage{siunitx,amsmath,xparse,xfp}
              usepackage{listofitems}
              begin{document}
              setsepchar{&}
              readlistxx{1&2&3&4&5}
              readlistyy{6&7&8&9&10}
              begin{frame}[fragile]
              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}
              makeatletter
              deftmp{}
              foreachitemzinxx{%
              ifnumzcnt=1relaxelseg@addto@macrotmp{&}fi%
              edeftmpA{fpeval{(z+yy[zcnt])/2}}%
              expandafterg@addto@macroexpandaftertmpexpandafter{tmpA}}
              makeatother
              readlistzz{tmp}
              foreachitemzinzz{zz[-zcnt] }
              end{frame}
              end{document}


              enter image description here






              share|improve this answer




























                1












                1








                1







                The listofitems package may give you at least some of what you need in terms of storing arrays.



                documentclass{beamer}
                usepackage{siunitx,amsmath,xparse,xfp}
                usepackage{listofitems}
                begin{document}
                setsepchar{&}
                readlistxx{1&2&3&4&5}
                readlistyy{6&7&8&9&10}
                begin{frame}[fragile]
                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}
                makeatletter
                deftmp{}
                foreachitemzinxx{%
                ifnumzcnt=1relaxelseg@addto@macrotmp{&}fi%
                edeftmpA{fpeval{(z+yy[zcnt])/2}}%
                expandafterg@addto@macroexpandaftertmpexpandafter{tmpA}}
                makeatother
                readlistzz{tmp}
                foreachitemzinzz{zz[-zcnt] }
                end{frame}
                end{document}


                enter image description here






                share|improve this answer















                The listofitems package may give you at least some of what you need in terms of storing arrays.



                documentclass{beamer}
                usepackage{siunitx,amsmath,xparse,xfp}
                usepackage{listofitems}
                begin{document}
                setsepchar{&}
                readlistxx{1&2&3&4&5}
                readlistyy{6&7&8&9&10}
                begin{frame}[fragile]
                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}
                makeatletter
                deftmp{}
                foreachitemzinxx{%
                ifnumzcnt=1relaxelseg@addto@macrotmp{&}fi%
                edeftmpA{fpeval{(z+yy[zcnt])/2}}%
                expandafterg@addto@macroexpandaftertmpexpandafter{tmpA}}
                makeatother
                readlistzz{tmp}
                foreachitemzinzz{zz[-zcnt] }
                end{frame}
                end{document}


                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 26 mins ago

























                answered 1 hour ago









                Steven B. SegletesSteven B. Segletes

                159k9204411




                159k9204411






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480828%2fhow-to-store-values-in-an-array%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                    Calculate evaluation metrics using cross_val_predict sklearn

                    Insert data from modal to MySQL (multiple modal on website)