Can `function`s called in `tl_map_` and `seq_map_function`s be defined with more than one argument?











up vote
0
down vote

favorite












In providing an answer to my recent post "Preserving spaces when scanning tl variables into a sequence using seq_set_split" Enrico Gregorio defined __rn_add:n to be called by tl_map_function. In experimenting with tl_map_ and seq_map_functions it occurred to me that the possibility of defining such functions having more than just one argument would be useful; for example __rn_add:nN might use #1 for the tl item and have #2 specify to which _seq variable to add the item. I assume the _function versions of tl_map and seq_map were intended to define processes for general use, while the _inline versions provide greatest flexibility but need to be written anew for each tl_map_ and seq_map_inline, or am I completely off the mark here?



documentclass{article}
usepackage[margin=1cm]{geometry}
usepackage{xparse}

ExplSyntaxOn
tl_new:N l_rn_auxOne_tl
tl_new:N l_rn_auxTwo_tl
seq_new:N l_rn_auxOne_seq
seq_new:N l_rn_auxTwo_seq

NewDocumentCommandmyScanText{m}
{
tl_set:Nn l_rn_auxOne_tl {#1}
seq_clear:N l_rn_auxOne_seq
% split at spaces
seq_set_split:Nnn l_rn_auxTwo_seq {~} { #1 }
% the first item is special, pop it out and split it
seq_pop_left:NN l_rn_auxTwo_seq l_rn_auxTwo_tl
tl_map_function:NN l_rn_auxTwo_tl __rn_add:n
% now do the other items, reinserting the space before them
seq_map_inline:Nn l_rn_auxTwo_seq
{
__rn_add:n { ~ }
tl_map_function:nN { ##1 } __rn_add:n
}
% print the data
textbf{tl~variable:}~tl_use:N l_rn_auxOne_tl\
textbf{seq~variable:}~seq_use:Nn l_rn_auxOne_seq {,}
}
cs_new_protected:Nn __rn_add:n
{
seq_put_right:Nn l_rn_auxOne_seq { #1 }
}
ExplSyntaxOff
%-----------------------
begin{document}

setlength{parindent}{0pt} % just for the example

myScanText{The quick brown fox jumps over the lazy dog.}

end{document}









share|improve this question


















  • 1




    It's definitely useful and I think something will appear in the future.
    – egreg
    yesterday










  • I conclude it cannot be done yet.
    – Reinhard Neuwirth
    yesterday















up vote
0
down vote

favorite












In providing an answer to my recent post "Preserving spaces when scanning tl variables into a sequence using seq_set_split" Enrico Gregorio defined __rn_add:n to be called by tl_map_function. In experimenting with tl_map_ and seq_map_functions it occurred to me that the possibility of defining such functions having more than just one argument would be useful; for example __rn_add:nN might use #1 for the tl item and have #2 specify to which _seq variable to add the item. I assume the _function versions of tl_map and seq_map were intended to define processes for general use, while the _inline versions provide greatest flexibility but need to be written anew for each tl_map_ and seq_map_inline, or am I completely off the mark here?



documentclass{article}
usepackage[margin=1cm]{geometry}
usepackage{xparse}

ExplSyntaxOn
tl_new:N l_rn_auxOne_tl
tl_new:N l_rn_auxTwo_tl
seq_new:N l_rn_auxOne_seq
seq_new:N l_rn_auxTwo_seq

NewDocumentCommandmyScanText{m}
{
tl_set:Nn l_rn_auxOne_tl {#1}
seq_clear:N l_rn_auxOne_seq
% split at spaces
seq_set_split:Nnn l_rn_auxTwo_seq {~} { #1 }
% the first item is special, pop it out and split it
seq_pop_left:NN l_rn_auxTwo_seq l_rn_auxTwo_tl
tl_map_function:NN l_rn_auxTwo_tl __rn_add:n
% now do the other items, reinserting the space before them
seq_map_inline:Nn l_rn_auxTwo_seq
{
__rn_add:n { ~ }
tl_map_function:nN { ##1 } __rn_add:n
}
% print the data
textbf{tl~variable:}~tl_use:N l_rn_auxOne_tl\
textbf{seq~variable:}~seq_use:Nn l_rn_auxOne_seq {,}
}
cs_new_protected:Nn __rn_add:n
{
seq_put_right:Nn l_rn_auxOne_seq { #1 }
}
ExplSyntaxOff
%-----------------------
begin{document}

setlength{parindent}{0pt} % just for the example

myScanText{The quick brown fox jumps over the lazy dog.}

end{document}









share|improve this question


















  • 1




    It's definitely useful and I think something will appear in the future.
    – egreg
    yesterday










  • I conclude it cannot be done yet.
    – Reinhard Neuwirth
    yesterday













up vote
0
down vote

favorite









up vote
0
down vote

favorite











In providing an answer to my recent post "Preserving spaces when scanning tl variables into a sequence using seq_set_split" Enrico Gregorio defined __rn_add:n to be called by tl_map_function. In experimenting with tl_map_ and seq_map_functions it occurred to me that the possibility of defining such functions having more than just one argument would be useful; for example __rn_add:nN might use #1 for the tl item and have #2 specify to which _seq variable to add the item. I assume the _function versions of tl_map and seq_map were intended to define processes for general use, while the _inline versions provide greatest flexibility but need to be written anew for each tl_map_ and seq_map_inline, or am I completely off the mark here?



documentclass{article}
usepackage[margin=1cm]{geometry}
usepackage{xparse}

ExplSyntaxOn
tl_new:N l_rn_auxOne_tl
tl_new:N l_rn_auxTwo_tl
seq_new:N l_rn_auxOne_seq
seq_new:N l_rn_auxTwo_seq

NewDocumentCommandmyScanText{m}
{
tl_set:Nn l_rn_auxOne_tl {#1}
seq_clear:N l_rn_auxOne_seq
% split at spaces
seq_set_split:Nnn l_rn_auxTwo_seq {~} { #1 }
% the first item is special, pop it out and split it
seq_pop_left:NN l_rn_auxTwo_seq l_rn_auxTwo_tl
tl_map_function:NN l_rn_auxTwo_tl __rn_add:n
% now do the other items, reinserting the space before them
seq_map_inline:Nn l_rn_auxTwo_seq
{
__rn_add:n { ~ }
tl_map_function:nN { ##1 } __rn_add:n
}
% print the data
textbf{tl~variable:}~tl_use:N l_rn_auxOne_tl\
textbf{seq~variable:}~seq_use:Nn l_rn_auxOne_seq {,}
}
cs_new_protected:Nn __rn_add:n
{
seq_put_right:Nn l_rn_auxOne_seq { #1 }
}
ExplSyntaxOff
%-----------------------
begin{document}

setlength{parindent}{0pt} % just for the example

myScanText{The quick brown fox jumps over the lazy dog.}

end{document}









share|improve this question













In providing an answer to my recent post "Preserving spaces when scanning tl variables into a sequence using seq_set_split" Enrico Gregorio defined __rn_add:n to be called by tl_map_function. In experimenting with tl_map_ and seq_map_functions it occurred to me that the possibility of defining such functions having more than just one argument would be useful; for example __rn_add:nN might use #1 for the tl item and have #2 specify to which _seq variable to add the item. I assume the _function versions of tl_map and seq_map were intended to define processes for general use, while the _inline versions provide greatest flexibility but need to be written anew for each tl_map_ and seq_map_inline, or am I completely off the mark here?



documentclass{article}
usepackage[margin=1cm]{geometry}
usepackage{xparse}

ExplSyntaxOn
tl_new:N l_rn_auxOne_tl
tl_new:N l_rn_auxTwo_tl
seq_new:N l_rn_auxOne_seq
seq_new:N l_rn_auxTwo_seq

NewDocumentCommandmyScanText{m}
{
tl_set:Nn l_rn_auxOne_tl {#1}
seq_clear:N l_rn_auxOne_seq
% split at spaces
seq_set_split:Nnn l_rn_auxTwo_seq {~} { #1 }
% the first item is special, pop it out and split it
seq_pop_left:NN l_rn_auxTwo_seq l_rn_auxTwo_tl
tl_map_function:NN l_rn_auxTwo_tl __rn_add:n
% now do the other items, reinserting the space before them
seq_map_inline:Nn l_rn_auxTwo_seq
{
__rn_add:n { ~ }
tl_map_function:nN { ##1 } __rn_add:n
}
% print the data
textbf{tl~variable:}~tl_use:N l_rn_auxOne_tl\
textbf{seq~variable:}~seq_use:Nn l_rn_auxOne_seq {,}
}
cs_new_protected:Nn __rn_add:n
{
seq_put_right:Nn l_rn_auxOne_seq { #1 }
}
ExplSyntaxOff
%-----------------------
begin{document}

setlength{parindent}{0pt} % just for the example

myScanText{The quick brown fox jumps over the lazy dog.}

end{document}






expl3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









Reinhard Neuwirth

1,47611322




1,47611322








  • 1




    It's definitely useful and I think something will appear in the future.
    – egreg
    yesterday










  • I conclude it cannot be done yet.
    – Reinhard Neuwirth
    yesterday














  • 1




    It's definitely useful and I think something will appear in the future.
    – egreg
    yesterday










  • I conclude it cannot be done yet.
    – Reinhard Neuwirth
    yesterday








1




1




It's definitely useful and I think something will appear in the future.
– egreg
yesterday




It's definitely useful and I think something will appear in the future.
– egreg
yesterday












I conclude it cannot be done yet.
– Reinhard Neuwirth
yesterday




I conclude it cannot be done yet.
– Reinhard Neuwirth
yesterday










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










If you need the expandability in a certain point, you can do



cs_set:Npn __rn_add:n #1 { rn_macro_with_two_args:nN { #1 } l_rn_addto_seq }
% ^ this before where you can, and then v this in an expandable context
tl_map_function:NN l_rn_auxii_tl __rn_add:n


But if you don't need expandability you can always do the inline version:



seq_map_inline:Nn l_rn_auxii_seq
{
__rn_add:n { ~ }
tl_map_inline:nn { ##1 }
{
rn_macro_with_two_args:nN { ###1 } l_rn_addto_seq
}
}





share|improve this answer





















  • I experimented with cascading inline versions, except that at the second level I needed four # to refer to the argument.
    – Reinhard Neuwirth
    yesterday













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',
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%2f460876%2fcan-functions-called-in-tl-map-and-seq-map-functions-be-defined-with-mo%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










If you need the expandability in a certain point, you can do



cs_set:Npn __rn_add:n #1 { rn_macro_with_two_args:nN { #1 } l_rn_addto_seq }
% ^ this before where you can, and then v this in an expandable context
tl_map_function:NN l_rn_auxii_tl __rn_add:n


But if you don't need expandability you can always do the inline version:



seq_map_inline:Nn l_rn_auxii_seq
{
__rn_add:n { ~ }
tl_map_inline:nn { ##1 }
{
rn_macro_with_two_args:nN { ###1 } l_rn_addto_seq
}
}





share|improve this answer





















  • I experimented with cascading inline versions, except that at the second level I needed four # to refer to the argument.
    – Reinhard Neuwirth
    yesterday

















up vote
2
down vote



accepted










If you need the expandability in a certain point, you can do



cs_set:Npn __rn_add:n #1 { rn_macro_with_two_args:nN { #1 } l_rn_addto_seq }
% ^ this before where you can, and then v this in an expandable context
tl_map_function:NN l_rn_auxii_tl __rn_add:n


But if you don't need expandability you can always do the inline version:



seq_map_inline:Nn l_rn_auxii_seq
{
__rn_add:n { ~ }
tl_map_inline:nn { ##1 }
{
rn_macro_with_two_args:nN { ###1 } l_rn_addto_seq
}
}





share|improve this answer





















  • I experimented with cascading inline versions, except that at the second level I needed four # to refer to the argument.
    – Reinhard Neuwirth
    yesterday















up vote
2
down vote



accepted







up vote
2
down vote



accepted






If you need the expandability in a certain point, you can do



cs_set:Npn __rn_add:n #1 { rn_macro_with_two_args:nN { #1 } l_rn_addto_seq }
% ^ this before where you can, and then v this in an expandable context
tl_map_function:NN l_rn_auxii_tl __rn_add:n


But if you don't need expandability you can always do the inline version:



seq_map_inline:Nn l_rn_auxii_seq
{
__rn_add:n { ~ }
tl_map_inline:nn { ##1 }
{
rn_macro_with_two_args:nN { ###1 } l_rn_addto_seq
}
}





share|improve this answer












If you need the expandability in a certain point, you can do



cs_set:Npn __rn_add:n #1 { rn_macro_with_two_args:nN { #1 } l_rn_addto_seq }
% ^ this before where you can, and then v this in an expandable context
tl_map_function:NN l_rn_auxii_tl __rn_add:n


But if you don't need expandability you can always do the inline version:



seq_map_inline:Nn l_rn_auxii_seq
{
__rn_add:n { ~ }
tl_map_inline:nn { ##1 }
{
rn_macro_with_two_args:nN { ###1 } l_rn_addto_seq
}
}






share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









Manuel

21k845105




21k845105












  • I experimented with cascading inline versions, except that at the second level I needed four # to refer to the argument.
    – Reinhard Neuwirth
    yesterday




















  • I experimented with cascading inline versions, except that at the second level I needed four # to refer to the argument.
    – Reinhard Neuwirth
    yesterday


















I experimented with cascading inline versions, except that at the second level I needed four # to refer to the argument.
– Reinhard Neuwirth
yesterday






I experimented with cascading inline versions, except that at the second level I needed four # to refer to the argument.
– Reinhard Neuwirth
yesterday




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460876%2fcan-functions-called-in-tl-map-and-seq-map-functions-be-defined-with-mo%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

Accessing regular linux commands in Huawei's Dopra Linux

Can't connect RFCOMM socket: Host is down

Kernel panic - not syncing: Fatal Exception in Interrupt