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
Does a windmilling propeller create more drag than a stopped propeller in an engine out scenario
Will this series of events work to drown a tarrasque?
Why does the U.S military use mercenaries?
Can ThermodynamicData be used with NSolve?
How was the blinking terminal cursor invented?
Former Employer just sent me an IP Agreement
How to get all possible paths in 0/1 matrix better way?
What color to choose as "danger" if the main color of my app is red
How to customize the pie chart background in PowerPoint?
how to create an executable file for an AppleScript?
Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?
Why is Drogon so much better in battle than Rhaegal and Viserion?
Should I twist DC power and ground wires from a power supply?
How can I monitor the bulk API limit?
Can the word crowd refer to just 10 people?
Can more than one instance of Bend Luck be applied to the same roll by multiple Wild Magic sorcerers?
Why is choosing a suitable thermodynamic potential important?
Quotient of Three Dimensional Torus by Permutation on Coordinates
Why using a variable as index of a list-item does not retrieve that item with clist_item:Nn?
Gaussian kernel density estimation with data from file
Why is the S-duct intake on the Tu-154 uniquely oblong?
Is there any deeper thematic meaning to the white horse that Arya finds in The Bells (S08E05)?
Taylor series leads to two different functions - why?
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
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
add a comment |
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
add a comment |
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
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
expl3 latex3 comma-separated-list
asked 4 hours ago
bp2017bp2017
942116
942116
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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
BTW, there's no benefit in pre-compiling the regex if you do it in every step of the loop ...
– Joseph Wright♦
2 hours ago
Isn'tclist_map_inline:Nneasier?
– egreg
1 hour ago
1
@egreg My guess was that the OP wants the position number too ...
– Joseph Wright♦
1 hour ago
add a comment |
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

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

add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
BTW, there's no benefit in pre-compiling the regex if you do it in every step of the loop ...
– Joseph Wright♦
2 hours ago
Isn'tclist_map_inline:Nneasier?
– egreg
1 hour ago
1
@egreg My guess was that the OP wants the position number too ...
– Joseph Wright♦
1 hour ago
add a comment |
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
BTW, there's no benefit in pre-compiling the regex if you do it in every step of the loop ...
– Joseph Wright♦
2 hours ago
Isn'tclist_map_inline:Nneasier?
– egreg
1 hour ago
1
@egreg My guess was that the OP wants the position number too ...
– Joseph Wright♦
1 hour ago
add a comment |
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
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
answered 4 hours ago
Joseph Wright♦Joseph 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♦
2 hours ago
Isn'tclist_map_inline:Nneasier?
– egreg
1 hour ago
1
@egreg My guess was that the OP wants the position number too ...
– Joseph Wright♦
1 hour ago
add a comment |
BTW, there's no benefit in pre-compiling the regex if you do it in every step of the loop ...
– Joseph Wright♦
2 hours ago
Isn'tclist_map_inline:Nneasier?
– 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♦
2 hours ago
BTW, there's no benefit in pre-compiling the regex if you do it in every step of the loop ...
– Joseph Wright♦
2 hours 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
add a comment |
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

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

add a comment |
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

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

add a comment |
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

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

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

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

edited 1 hour ago
answered 1 hour ago
egregegreg
742k8919423274
742k8919423274
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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