modular macro list structure to iterate it












0















Based on the Wipet's answer, and with the same learning spirit, about the iterate loop "for", it's interesting to find out how the proposed "for loop" could be more modular. I want to pass, as an argument, the iterable list purposed in the above example.



documentclass[a4paper]{article}
usepackage{pst-solides3d}

%%% FOR LOOP %%%
makeatletter
longdeffor#1in#2#3{expandafterdefcsname b:string#1endcsname{#3}%
@forinA#1#2;}
longdef@forinA#1#2;{ifx#2else
def#1{#2}csname b:string#1endcsname expandafter@forinAexpandafter#1fi}
%%%%%%%%%%%%%%%%%%
makeatother

%% Variables%%
pgfmathparse{1.2}edeflinkLength{pgfmathresult}
pgfmathparse{0.2}edefjointRadio{pgfmathresult}
pgfmathparse{0.6}edefjointLength{pgfmathresult}

newcommand{iterating}{
%%% point's structure %%%
fori in {%
0 0 0;% N°0
0 0 0;% N°1
0 0 linkLength;% N°2
0 0 jointLength;% N°3
0 {jointLength*0.5} {linkLength + jointRadio};% N°4
}
{%
ipar
%... call to several macros
}%
}
begin{document}

iterating

end{document}


The code behavior is correct for my purpose.



0 0 0
0 0 0
0 0 1.2
0 0 0.6
0 0.6*0.5 1.2+ 0.2


This list, is an implicit list, with several variables and arithmetic operation in each component. So the main idea is passing the list as a macro, something like newcommand{list}{0 0 0;0 0 0;0 0 linkLength;0 0 jointLength;0 {jointLength*0.5} {linkLength + jointRadio}} and call it as fori in list. I don't understand which modifications be needed in for declaration to reach this behavior.
(i realize that this behavior could be reached using foreach statement but i need to understand how could be done)



Any ideas, will be well received.










share|improve this question



























    0















    Based on the Wipet's answer, and with the same learning spirit, about the iterate loop "for", it's interesting to find out how the proposed "for loop" could be more modular. I want to pass, as an argument, the iterable list purposed in the above example.



    documentclass[a4paper]{article}
    usepackage{pst-solides3d}

    %%% FOR LOOP %%%
    makeatletter
    longdeffor#1in#2#3{expandafterdefcsname b:string#1endcsname{#3}%
    @forinA#1#2;}
    longdef@forinA#1#2;{ifx#2else
    def#1{#2}csname b:string#1endcsname expandafter@forinAexpandafter#1fi}
    %%%%%%%%%%%%%%%%%%
    makeatother

    %% Variables%%
    pgfmathparse{1.2}edeflinkLength{pgfmathresult}
    pgfmathparse{0.2}edefjointRadio{pgfmathresult}
    pgfmathparse{0.6}edefjointLength{pgfmathresult}

    newcommand{iterating}{
    %%% point's structure %%%
    fori in {%
    0 0 0;% N°0
    0 0 0;% N°1
    0 0 linkLength;% N°2
    0 0 jointLength;% N°3
    0 {jointLength*0.5} {linkLength + jointRadio};% N°4
    }
    {%
    ipar
    %... call to several macros
    }%
    }
    begin{document}

    iterating

    end{document}


    The code behavior is correct for my purpose.



    0 0 0
    0 0 0
    0 0 1.2
    0 0 0.6
    0 0.6*0.5 1.2+ 0.2


    This list, is an implicit list, with several variables and arithmetic operation in each component. So the main idea is passing the list as a macro, something like newcommand{list}{0 0 0;0 0 0;0 0 linkLength;0 0 jointLength;0 {jointLength*0.5} {linkLength + jointRadio}} and call it as fori in list. I don't understand which modifications be needed in for declaration to reach this behavior.
    (i realize that this behavior could be reached using foreach statement but i need to understand how could be done)



    Any ideas, will be well received.










    share|improve this question

























      0












      0








      0








      Based on the Wipet's answer, and with the same learning spirit, about the iterate loop "for", it's interesting to find out how the proposed "for loop" could be more modular. I want to pass, as an argument, the iterable list purposed in the above example.



      documentclass[a4paper]{article}
      usepackage{pst-solides3d}

      %%% FOR LOOP %%%
      makeatletter
      longdeffor#1in#2#3{expandafterdefcsname b:string#1endcsname{#3}%
      @forinA#1#2;}
      longdef@forinA#1#2;{ifx#2else
      def#1{#2}csname b:string#1endcsname expandafter@forinAexpandafter#1fi}
      %%%%%%%%%%%%%%%%%%
      makeatother

      %% Variables%%
      pgfmathparse{1.2}edeflinkLength{pgfmathresult}
      pgfmathparse{0.2}edefjointRadio{pgfmathresult}
      pgfmathparse{0.6}edefjointLength{pgfmathresult}

      newcommand{iterating}{
      %%% point's structure %%%
      fori in {%
      0 0 0;% N°0
      0 0 0;% N°1
      0 0 linkLength;% N°2
      0 0 jointLength;% N°3
      0 {jointLength*0.5} {linkLength + jointRadio};% N°4
      }
      {%
      ipar
      %... call to several macros
      }%
      }
      begin{document}

      iterating

      end{document}


      The code behavior is correct for my purpose.



      0 0 0
      0 0 0
      0 0 1.2
      0 0 0.6
      0 0.6*0.5 1.2+ 0.2


      This list, is an implicit list, with several variables and arithmetic operation in each component. So the main idea is passing the list as a macro, something like newcommand{list}{0 0 0;0 0 0;0 0 linkLength;0 0 jointLength;0 {jointLength*0.5} {linkLength + jointRadio}} and call it as fori in list. I don't understand which modifications be needed in for declaration to reach this behavior.
      (i realize that this behavior could be reached using foreach statement but i need to understand how could be done)



      Any ideas, will be well received.










      share|improve this question














      Based on the Wipet's answer, and with the same learning spirit, about the iterate loop "for", it's interesting to find out how the proposed "for loop" could be more modular. I want to pass, as an argument, the iterable list purposed in the above example.



      documentclass[a4paper]{article}
      usepackage{pst-solides3d}

      %%% FOR LOOP %%%
      makeatletter
      longdeffor#1in#2#3{expandafterdefcsname b:string#1endcsname{#3}%
      @forinA#1#2;}
      longdef@forinA#1#2;{ifx#2else
      def#1{#2}csname b:string#1endcsname expandafter@forinAexpandafter#1fi}
      %%%%%%%%%%%%%%%%%%
      makeatother

      %% Variables%%
      pgfmathparse{1.2}edeflinkLength{pgfmathresult}
      pgfmathparse{0.2}edefjointRadio{pgfmathresult}
      pgfmathparse{0.6}edefjointLength{pgfmathresult}

      newcommand{iterating}{
      %%% point's structure %%%
      fori in {%
      0 0 0;% N°0
      0 0 0;% N°1
      0 0 linkLength;% N°2
      0 0 jointLength;% N°3
      0 {jointLength*0.5} {linkLength + jointRadio};% N°4
      }
      {%
      ipar
      %... call to several macros
      }%
      }
      begin{document}

      iterating

      end{document}


      The code behavior is correct for my purpose.



      0 0 0
      0 0 0
      0 0 1.2
      0 0 0.6
      0 0.6*0.5 1.2+ 0.2


      This list, is an implicit list, with several variables and arithmetic operation in each component. So the main idea is passing the list as a macro, something like newcommand{list}{0 0 0;0 0 0;0 0 linkLength;0 0 jointLength;0 {jointLength*0.5} {linkLength + jointRadio}} and call it as fori in list. I don't understand which modifications be needed in for declaration to reach this behavior.
      (i realize that this behavior could be reached using foreach statement but i need to understand how could be done)



      Any ideas, will be well received.







      macros lists pst-solides3d literate-programming






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 13 mins ago









      Rene ValenzuelaRene Valenzuela

      114




      114






















          0






          active

          oldest

          votes











          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%2f477066%2fmodular-macro-list-structure-to-iterate-it%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f477066%2fmodular-macro-list-structure-to-iterate-it%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)