Why using a variable as index of a list-item does not retrieve that item with clist_item:Nn?formatting real numbers using LaTeX3listings package and latex3 variableWorking with clist indices in LaTeX3Inline Mapping Bug?expl3 code with tabularxHow to manipulate items of a SplitList while processing?What is it I am doing wrong using `tl_case:Nn …`?Proper LaTeX3 syntax for usepackage<name of .sty file> - ProvidesPackage<name of .sty file>Modeling a mapping from strings to lists of strings in LaTeX3expl3-strategy to automatically update the title of a document, depending on its content

FIFO data structure in pure C

Can the word crowd refer to just 10 people?

What technology would Dwarves need to forge titanium?

Why does the U.S military use mercenaries?

Shortest amud or daf in Shas?

Is there any deeper thematic meaning to the white horse that Arya finds in The Bells (S08E05)?

How do I balance a campaign consisting of four kobold PCs?

How would fantasy dwarves exist, realistically?

Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?

I recently started my machine learning PhD and I have absolutely no idea what I'm doing

Can 2 light bulbs of 120V in series be used on 230V AC?

Why use a retrograde orbit?

Was Tyrion always a poor strategist?

How to draw pentagram-like shape in Latex?

Are there any symmetric cryptosystems based on computational complexity assumptions?

Driving a school bus in the USA

How was the blinking terminal cursor invented?

Why is so much ransomware breakable?

RegEx with d doesn’t work in if-else statement with [[

Hotel booking: Why is Agoda much cheaper than booking.com?

Quotient of Three Dimensional Torus by Permutation on Coordinates

Can an airline pilot be prosecuted for killing an unruly passenger who could not be physically restrained?

What do you call bracelets you wear around the legs?

Why does the setUID bit work inconsistently?



Why using a variable as index of a list-item does not retrieve that item with clist_item:Nn?


formatting real numbers using LaTeX3listings package and latex3 variableWorking with clist indices in LaTeX3Inline Mapping Bug?expl3 code with tabularxHow to manipulate items of a SplitList while processing?What is it I am doing wrong using `tl_case:Nn …`?Proper LaTeX3 syntax for usepackage<name of .sty file> - ProvidesPackage<name of .sty file>Modeling a mapping from strings to lists of strings in LaTeX3expl3-strategy to automatically update the title of a document, depending on its content













3















For some reason, using a variable as index of a list-item does not work for retrieving that item. But using a number instead of a variable works. Why?



documentclassstandalone
usepackageexpl3
ExplSyntaxOn
begindocument

clist_new:NmyList
clist_set:NnmyList1,south

int_new:NmyCounter
int_set:NnmyCounter1
int_do_until:nNnnmyCounter=clist_count:NmyList+1
regex_set:NnmyExp[0-9]+
% following line doesn't work
%regex_match:NnTmyExpclist_item:NnmyListint_use:NmyCounter
% but as soon as we change int_use:NmyCounter to 1, it works
regex_match:NnTmyExpclist_item:NnmyList1
(is a number) % output

int_incr:NmyCounter


enddocument









share|improve this question


























    3















    For some reason, using a variable as index of a list-item does not work for retrieving that item. But using a number instead of a variable works. Why?



    documentclassstandalone
    usepackageexpl3
    ExplSyntaxOn
    begindocument

    clist_new:NmyList
    clist_set:NnmyList1,south

    int_new:NmyCounter
    int_set:NnmyCounter1
    int_do_until:nNnnmyCounter=clist_count:NmyList+1
    regex_set:NnmyExp[0-9]+
    % following line doesn't work
    %regex_match:NnTmyExpclist_item:NnmyListint_use:NmyCounter
    % but as soon as we change int_use:NmyCounter to 1, it works
    regex_match:NnTmyExpclist_item:NnmyList1
    (is a number) % output

    int_incr:NmyCounter


    enddocument









    share|improve this question
























      3












      3








      3








      For some reason, using a variable as index of a list-item does not work for retrieving that item. But using a number instead of a variable works. Why?



      documentclassstandalone
      usepackageexpl3
      ExplSyntaxOn
      begindocument

      clist_new:NmyList
      clist_set:NnmyList1,south

      int_new:NmyCounter
      int_set:NnmyCounter1
      int_do_until:nNnnmyCounter=clist_count:NmyList+1
      regex_set:NnmyExp[0-9]+
      % following line doesn't work
      %regex_match:NnTmyExpclist_item:NnmyListint_use:NmyCounter
      % but as soon as we change int_use:NmyCounter to 1, it works
      regex_match:NnTmyExpclist_item:NnmyList1
      (is a number) % output

      int_incr:NmyCounter


      enddocument









      share|improve this question














      For some reason, using a variable as index of a list-item does not work for retrieving that item. But using a number instead of a variable works. Why?



      documentclassstandalone
      usepackageexpl3
      ExplSyntaxOn
      begindocument

      clist_new:NmyList
      clist_set:NnmyList1,south

      int_new:NmyCounter
      int_set:NnmyCounter1
      int_do_until:nNnnmyCounter=clist_count:NmyList+1
      regex_set:NnmyExp[0-9]+
      % following line doesn't work
      %regex_match:NnTmyExpclist_item:NnmyListint_use:NmyCounter
      % but as soon as we change int_use:NmyCounter to 1, it works
      regex_match:NnTmyExpclist_item:NnmyList1
      (is a number) % output

      int_incr:NmyCounter


      enddocument






      expl3 latex3 comma-separated-list






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 4 hours ago









      bp2017bp2017

      942116




      942116




















          2 Answers
          2






          active

          oldest

          votes


















          4














          You are using a regex against the literal text clist_item:NnmyListint_use:NmyCounter, not the result of executing it. In the case where you use an explicit 1, that works, but not when you have no 1 present.



          Fixing that by expansion, and also using standard variable names plus a step loop (seems easier here), I'd have



          documentclassstandalone
          usepackageexpl3

          begindocument
          ExplSyntaxOn
          clist_set:Nn l_tmpa_clist 1 , south
          regex_set:Nn l_tmpa_regex [0-9]+
          int_step_inline:nn clist_count:N l_tmpa_clist

          exp_args:NNf regex_match:NnT l_tmpa_regex
          clist_item:Nn l_tmpa_clist #1
          (is ~ a ~ number )

          ExplSyntaxOff

          enddocument





          share|improve this answer























          • BTW, there's no benefit in pre-compiling the regex if you do it in every step of the loop ...

            – Joseph Wright
            1 hour ago











          • Isn't clist_map_inline:Nn easier?

            – egreg
            1 hour ago






          • 1





            @egreg My guess was that the OP wants the position number too ...

            – Joseph Wright
            1 hour ago


















          4














          The argument type n in regex_match:NnT states that the argument is passed “literally”, with no processing, but you need the item, not the instructions needed to retrieve it. You could define a variant



          prg_generate_conditional_variant:Nnn regex_match:nn ne T,F,TF 


          and use regex_match:NeT, but it's actually much easier with clist_map_inline:Nn that will access the clist's items one at a time:



          documentclassarticle
          usepackageexpl3

          begindocument

          ExplSyntaxOn

          clist_new:N l_bp_mylist_clist
          clist_set:Nn l_bp_mylist_clist 1,south

          clist_map_inline:Nn l_bp_mylist_clist

          regex_match:nnTF [0-9]+ #1
          #1~is~a~number par
          #1~is~not~a~number par


          ExplSyntaxOff

          enddocument


          enter image description here



          If you need to use the item number,



          documentclassarticle
          usepackageexpl3

          begindocument

          ExplSyntaxOn

          clist_new:N l_bp_mylist_clist
          clist_set:Nn l_bp_mylist_clist 1,south

          prg_generate_conditional_variant:Nnn regex_match:nn ne T,F,TF

          int_step_inline:nn clist_count:N l_bp_mylist_clist

          regex_match:neTF [0-9]+ clist_item:Nn l_bp_mylist_clist #1
          Item~#1~`clist_item:Nn l_bp_mylist_clist #1 '~is~a~number par
          Item~#1~`clist_item:Nn l_bp_mylist_clist #1 '~is~not~a~number par


          ExplSyntaxOff

          enddocument


          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%2f491180%2fwhy-using-a-variable-as-index-of-a-list-item-does-not-retrieve-that-item-with-c%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









            4














            You are using a regex against the literal text clist_item:NnmyListint_use:NmyCounter, not the result of executing it. In the case where you use an explicit 1, that works, but not when you have no 1 present.



            Fixing that by expansion, and also using standard variable names plus a step loop (seems easier here), I'd have



            documentclassstandalone
            usepackageexpl3

            begindocument
            ExplSyntaxOn
            clist_set:Nn l_tmpa_clist 1 , south
            regex_set:Nn l_tmpa_regex [0-9]+
            int_step_inline:nn clist_count:N l_tmpa_clist

            exp_args:NNf regex_match:NnT l_tmpa_regex
            clist_item:Nn l_tmpa_clist #1
            (is ~ a ~ number )

            ExplSyntaxOff

            enddocument





            share|improve this answer























            • BTW, there's no benefit in pre-compiling the regex if you do it in every step of the loop ...

              – Joseph Wright
              1 hour ago











            • Isn't clist_map_inline:Nn easier?

              – egreg
              1 hour ago






            • 1





              @egreg My guess was that the OP wants the position number too ...

              – Joseph Wright
              1 hour ago















            4














            You are using a regex against the literal text clist_item:NnmyListint_use:NmyCounter, not the result of executing it. In the case where you use an explicit 1, that works, but not when you have no 1 present.



            Fixing that by expansion, and also using standard variable names plus a step loop (seems easier here), I'd have



            documentclassstandalone
            usepackageexpl3

            begindocument
            ExplSyntaxOn
            clist_set:Nn l_tmpa_clist 1 , south
            regex_set:Nn l_tmpa_regex [0-9]+
            int_step_inline:nn clist_count:N l_tmpa_clist

            exp_args:NNf regex_match:NnT l_tmpa_regex
            clist_item:Nn l_tmpa_clist #1
            (is ~ a ~ number )

            ExplSyntaxOff

            enddocument





            share|improve this answer























            • BTW, there's no benefit in pre-compiling the regex if you do it in every step of the loop ...

              – Joseph Wright
              1 hour ago











            • Isn't clist_map_inline:Nn easier?

              – egreg
              1 hour ago






            • 1





              @egreg My guess was that the OP wants the position number too ...

              – Joseph Wright
              1 hour ago













            4












            4








            4







            You are using a regex against the literal text clist_item:NnmyListint_use:NmyCounter, not the result of executing it. In the case where you use an explicit 1, that works, but not when you have no 1 present.



            Fixing that by expansion, and also using standard variable names plus a step loop (seems easier here), I'd have



            documentclassstandalone
            usepackageexpl3

            begindocument
            ExplSyntaxOn
            clist_set:Nn l_tmpa_clist 1 , south
            regex_set:Nn l_tmpa_regex [0-9]+
            int_step_inline:nn clist_count:N l_tmpa_clist

            exp_args:NNf regex_match:NnT l_tmpa_regex
            clist_item:Nn l_tmpa_clist #1
            (is ~ a ~ number )

            ExplSyntaxOff

            enddocument





            share|improve this answer













            You are using a regex against the literal text clist_item:NnmyListint_use:NmyCounter, not the result of executing it. In the case where you use an explicit 1, that works, but not when you have no 1 present.



            Fixing that by expansion, and also using standard variable names plus a step loop (seems easier here), I'd have



            documentclassstandalone
            usepackageexpl3

            begindocument
            ExplSyntaxOn
            clist_set:Nn l_tmpa_clist 1 , south
            regex_set:Nn l_tmpa_regex [0-9]+
            int_step_inline:nn clist_count:N l_tmpa_clist

            exp_args:NNf regex_match:NnT l_tmpa_regex
            clist_item:Nn l_tmpa_clist #1
            (is ~ a ~ number )

            ExplSyntaxOff

            enddocument






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 4 hours ago









            Joseph WrightJoseph Wright

            207k23568897




            207k23568897












            • BTW, there's no benefit in pre-compiling the regex if you do it in every step of the loop ...

              – Joseph Wright
              1 hour ago











            • Isn't clist_map_inline:Nn easier?

              – egreg
              1 hour ago






            • 1





              @egreg My guess was that the OP wants the position number too ...

              – Joseph Wright
              1 hour ago

















            • BTW, there's no benefit in pre-compiling the regex if you do it in every step of the loop ...

              – Joseph Wright
              1 hour ago











            • Isn't clist_map_inline:Nn easier?

              – egreg
              1 hour ago






            • 1





              @egreg My guess was that the OP wants the position number too ...

              – Joseph Wright
              1 hour ago
















            BTW, there's no benefit in pre-compiling the regex if you do it in every step of the loop ...

            – Joseph Wright
            1 hour ago





            BTW, there's no benefit in pre-compiling the regex if you do it in every step of the loop ...

            – Joseph Wright
            1 hour ago













            Isn't clist_map_inline:Nn easier?

            – egreg
            1 hour ago





            Isn't clist_map_inline:Nn easier?

            – egreg
            1 hour ago




            1




            1





            @egreg My guess was that the OP wants the position number too ...

            – Joseph Wright
            1 hour ago





            @egreg My guess was that the OP wants the position number too ...

            – Joseph Wright
            1 hour ago











            4














            The argument type n in regex_match:NnT states that the argument is passed “literally”, with no processing, but you need the item, not the instructions needed to retrieve it. You could define a variant



            prg_generate_conditional_variant:Nnn regex_match:nn ne T,F,TF 


            and use regex_match:NeT, but it's actually much easier with clist_map_inline:Nn that will access the clist's items one at a time:



            documentclassarticle
            usepackageexpl3

            begindocument

            ExplSyntaxOn

            clist_new:N l_bp_mylist_clist
            clist_set:Nn l_bp_mylist_clist 1,south

            clist_map_inline:Nn l_bp_mylist_clist

            regex_match:nnTF [0-9]+ #1
            #1~is~a~number par
            #1~is~not~a~number par


            ExplSyntaxOff

            enddocument


            enter image description here



            If you need to use the item number,



            documentclassarticle
            usepackageexpl3

            begindocument

            ExplSyntaxOn

            clist_new:N l_bp_mylist_clist
            clist_set:Nn l_bp_mylist_clist 1,south

            prg_generate_conditional_variant:Nnn regex_match:nn ne T,F,TF

            int_step_inline:nn clist_count:N l_bp_mylist_clist

            regex_match:neTF [0-9]+ clist_item:Nn l_bp_mylist_clist #1
            Item~#1~`clist_item:Nn l_bp_mylist_clist #1 '~is~a~number par
            Item~#1~`clist_item:Nn l_bp_mylist_clist #1 '~is~not~a~number par


            ExplSyntaxOff

            enddocument


            enter image description here






            share|improve this answer





























              4














              The argument type n in regex_match:NnT states that the argument is passed “literally”, with no processing, but you need the item, not the instructions needed to retrieve it. You could define a variant



              prg_generate_conditional_variant:Nnn regex_match:nn ne T,F,TF 


              and use regex_match:NeT, but it's actually much easier with clist_map_inline:Nn that will access the clist's items one at a time:



              documentclassarticle
              usepackageexpl3

              begindocument

              ExplSyntaxOn

              clist_new:N l_bp_mylist_clist
              clist_set:Nn l_bp_mylist_clist 1,south

              clist_map_inline:Nn l_bp_mylist_clist

              regex_match:nnTF [0-9]+ #1
              #1~is~a~number par
              #1~is~not~a~number par


              ExplSyntaxOff

              enddocument


              enter image description here



              If you need to use the item number,



              documentclassarticle
              usepackageexpl3

              begindocument

              ExplSyntaxOn

              clist_new:N l_bp_mylist_clist
              clist_set:Nn l_bp_mylist_clist 1,south

              prg_generate_conditional_variant:Nnn regex_match:nn ne T,F,TF

              int_step_inline:nn clist_count:N l_bp_mylist_clist

              regex_match:neTF [0-9]+ clist_item:Nn l_bp_mylist_clist #1
              Item~#1~`clist_item:Nn l_bp_mylist_clist #1 '~is~a~number par
              Item~#1~`clist_item:Nn l_bp_mylist_clist #1 '~is~not~a~number par


              ExplSyntaxOff

              enddocument


              enter image description here






              share|improve this answer



























                4












                4








                4







                The argument type n in regex_match:NnT states that the argument is passed “literally”, with no processing, but you need the item, not the instructions needed to retrieve it. You could define a variant



                prg_generate_conditional_variant:Nnn regex_match:nn ne T,F,TF 


                and use regex_match:NeT, but it's actually much easier with clist_map_inline:Nn that will access the clist's items one at a time:



                documentclassarticle
                usepackageexpl3

                begindocument

                ExplSyntaxOn

                clist_new:N l_bp_mylist_clist
                clist_set:Nn l_bp_mylist_clist 1,south

                clist_map_inline:Nn l_bp_mylist_clist

                regex_match:nnTF [0-9]+ #1
                #1~is~a~number par
                #1~is~not~a~number par


                ExplSyntaxOff

                enddocument


                enter image description here



                If you need to use the item number,



                documentclassarticle
                usepackageexpl3

                begindocument

                ExplSyntaxOn

                clist_new:N l_bp_mylist_clist
                clist_set:Nn l_bp_mylist_clist 1,south

                prg_generate_conditional_variant:Nnn regex_match:nn ne T,F,TF

                int_step_inline:nn clist_count:N l_bp_mylist_clist

                regex_match:neTF [0-9]+ clist_item:Nn l_bp_mylist_clist #1
                Item~#1~`clist_item:Nn l_bp_mylist_clist #1 '~is~a~number par
                Item~#1~`clist_item:Nn l_bp_mylist_clist #1 '~is~not~a~number par


                ExplSyntaxOff

                enddocument


                enter image description here






                share|improve this answer















                The argument type n in regex_match:NnT states that the argument is passed “literally”, with no processing, but you need the item, not the instructions needed to retrieve it. You could define a variant



                prg_generate_conditional_variant:Nnn regex_match:nn ne T,F,TF 


                and use regex_match:NeT, but it's actually much easier with clist_map_inline:Nn that will access the clist's items one at a time:



                documentclassarticle
                usepackageexpl3

                begindocument

                ExplSyntaxOn

                clist_new:N l_bp_mylist_clist
                clist_set:Nn l_bp_mylist_clist 1,south

                clist_map_inline:Nn l_bp_mylist_clist

                regex_match:nnTF [0-9]+ #1
                #1~is~a~number par
                #1~is~not~a~number par


                ExplSyntaxOff

                enddocument


                enter image description here



                If you need to use the item number,



                documentclassarticle
                usepackageexpl3

                begindocument

                ExplSyntaxOn

                clist_new:N l_bp_mylist_clist
                clist_set:Nn l_bp_mylist_clist 1,south

                prg_generate_conditional_variant:Nnn regex_match:nn ne T,F,TF

                int_step_inline:nn clist_count:N l_bp_mylist_clist

                regex_match:neTF [0-9]+ clist_item:Nn l_bp_mylist_clist #1
                Item~#1~`clist_item:Nn l_bp_mylist_clist #1 '~is~a~number par
                Item~#1~`clist_item:Nn l_bp_mylist_clist #1 '~is~not~a~number par


                ExplSyntaxOff

                enddocument


                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 1 hour ago

























                answered 1 hour ago









                egregegreg

                742k8919423274




                742k8919423274



























                    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%2f491180%2fwhy-using-a-variable-as-index-of-a-list-item-does-not-retrieve-that-item-with-c%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

                    Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                    Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                    In Tikz, how to set a node's label alignment to the left?Rotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?Numerical conditional within tikz keys?TikZ/ERD: node (=Entity) label on the insideLine up nested tikz enviroments or how to get rid of themVertically align a tikzpicture and forestDrawing tikz line in the margin for multiple pagesLongtable, contained tikz, padding, custom columns, and an alignment issueTikZ: define arrow starting position based on style and format node labelAlign node name in Tikz