expl3: clist에 추가할 때 모든 항목을 한 번 확장합니다.

expl3: clist에 추가할 때 모든 항목을 한 번 확장합니다.

clist에 항목을 추가하고 모든 항목을 한 번 확장하고 싶습니다. 그런데 (내 눈에는) 내츄럴은 \clist_set:No첫 번째 항목만 확장해서 생각만큼 작동하지 않았다.

\documentclass{article}
\usepackage{expl3}

\begin{document}
\ExplSyntaxOn
\def\testa{blub}
\def\testb{blabla}
\clist_set:No\mylist{\testa,\testb}
\clist_show:N\mylist
\ExplSyntaxOff
\end{document}

 The comma list \mylist contains the items (without outer braces):
>  {blub}
>  {\testb }.

그렇다면 이를 수행하는 올바른 방법은 무엇입니까? 실제로 루프를 사용해야 합니까?

답변1

변형 은 o중괄호 뒤의 첫 번째 토큰을 확장합니다.

항목을 하나씩 추가해야 합니다.

\clist_new:N \l_ulrike_mylist_clist

\clist_map_inline:nn { \testa , \testb }
 {
  \clist_put_right:No \l_ulrike_mylist_clist { #1 }
 }

물론 이에 대한 구문 설탕을 구축할 수 있습니다.

\cs_new_protected:Nn \ulrike_clist_set_exp:Nn
 {
  \clist_clear:N #1
  \clist_map_inline:nn { #2 }
   {
    \clist_put_right:No #1 { ##1 }
   }
 }

관련 정보