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

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

Divisor Rich and Poor Numbers

Why are there five extra turns in tournament Magic?

Can more than one instance of Bend Luck be applied to the same roll by multiple Wild Magic sorcerers?

How do you cope with rejection?

Does the US Supreme Court vote using secret ballots?

Why does the U.S military use mercenaries?

Can a generation ship withstand its own oxygen and daily wear for many thousands of years?

What's is the easiest way to purchase a stock and hold it

on the truth quest vs in the quest for truth

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

Is my company merging branches wrong?

Using `printf` to print variable containing `%` percent sign results in "bash: printf: `p': invalid format character"

Pedaling at different gear ratios on flat terrain: what's the point?

How can sister protect herself from impulse purchases with a credit card?

What color to choose as "danger" if the main color of my app is red

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

How to get all possible paths in 0/1 matrix better way?

Can ThermodynamicData be used with NSolve?

Is it possible to determine from only a photo of a cityscape whether it was taken close with wide angle or from a distance with zoom?

Is it standard to have the first week's pay indefinitely withheld?

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

Largest memory peripheral for Sinclair ZX81?

How would fantasy dwarves exist, realistically?



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 6 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
            3 hours ago











          • Isn't clist_map_inline:Nn easier?

            – egreg
            3 hours ago






          • 1





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

            – Joseph Wright
            3 hours 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
              3 hours ago











            • Isn't clist_map_inline:Nn easier?

              – egreg
              3 hours ago






            • 1





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

              – Joseph Wright
              3 hours 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
              3 hours ago











            • Isn't clist_map_inline:Nn easier?

              – egreg
              3 hours ago






            • 1





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

              – Joseph Wright
              3 hours 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 6 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
              3 hours ago











            • Isn't clist_map_inline:Nn easier?

              – egreg
              3 hours ago






            • 1





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

              – Joseph Wright
              3 hours ago

















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

              – Joseph Wright
              3 hours ago











            • Isn't clist_map_inline:Nn easier?

              – egreg
              3 hours ago






            • 1





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

              – Joseph Wright
              3 hours ago
















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

            – Joseph Wright
            3 hours ago





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

            – Joseph Wright
            3 hours ago













            Isn't clist_map_inline:Nn easier?

            – egreg
            3 hours ago





            Isn't clist_map_inline:Nn easier?

            – egreg
            3 hours ago




            1




            1





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

            – Joseph Wright
            3 hours ago





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

            – Joseph Wright
            3 hours 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 2 hours ago

























                answered 3 hours 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

                    Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

                    The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

                    19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу