我确信我遗漏了一些琐碎的东西(仍在学习 LaTeX3),但这看起来很奇怪:prop_map_inline 不会将值返回为 clist,即使它们是?
\documentclass{article}
\begin{document}
\ExplSyntaxOn
\prop_new:N \someProp
% put some data into prop:
\clist_set:Nn \l_tmpa_cl {a,b,c}
\clist_use:Nn \l_tmpa_cl {\ ---\ }
\prop_put:NnV \someProp {keyA} {\l_tmpa_cl}
\par
\clist_set:Nn \l_tmpa_cl {u,v,w,x,y,z}
\clist_use:Nn \l_tmpa_cl {\ ---\ }
\prop_put:NnV \someProp {keyB} {\l_tmpa_cl}
\par
% Direct access works fine; I get back a clist:
\prop_get:NnN \someProp {keyA} \l_tmpb_cl
\clist_use:Nn \l_tmpb_cl {\ ---\ }
\par
% When iterating over property, value is no longer
% a clist, but just a string?
\prop_map_inline:Nn \someProp { Key\ #1; \
Values\ list:\ \clist_use:Nn #2 {\ ---\ }
\par }
\prop_log:N \someProp
\ExplSyntaxOff
\end{document}
日志档案:
The property list \someProp contains the pairs (without outer braces):
> {keyA} => {a,b,c}
> {keyB} => {u,v,w,x,y,z}.
这似乎理应如此。??
答案1
您所需要的\clist_use:nn
不是#2
变量(如\l_tmpa_clist
),而只是一个标记列表(a,b,c
)。
\documentclass{article}
\begin{document}
\ExplSyntaxOn
\prop_new:N \l_karl_some_prop
% put some data into prop:
\clist_set:Nn \l_tmpa_clist {a,b,c}
\clist_use:Nn \l_tmpa_clist {\ ---\ }
\prop_put:NnV \l_karl_some_prop {keyA}\l_tmpa_clist
\par
\clist_set:Nn \l_tmpa_clist {u,v,w,x,y,z}
\clist_use:Nn \l_tmpa_clist {\ ---\ }
\prop_put:NnV \l_karl_some_prop {keyB}\l_tmpa_clist
\par
\prop_map_inline:Nn \l_karl_some_prop
{
Key\ #1; \
Values\ list:\ \clist_use:nn {#2} {\ ---\ }
\par
}
\ExplSyntaxOff
\end{document}