This question is related to Execute list of commands generated by pairing elements from two \clist s or \seq s.
I am trying to perform a sequence of commands of the form
\def\alpha {^^^^03b1}
with \seq_\map_pairwise_function:ccN. I would prefer to pass in arguments in the form "03B1 rather than ^^^^03b1 and I think I have figured out how to do that. This code appears to function correctly.
\documentclass{article}
\usepackage{fontspec}
\usepackage{nopageno}
\newfontfamily\mathematica{Mathematica}[%
NFSSFamily=mathematica,Scale=MatchUppercase,%
Extension=.ttf,%
UprightFont=,%
BoldFont=-Bold]
\DeclareSymbolFont{wm}{TU}{mathematica}{m}{n}
\DeclareSymbolFont{wmb}{TU}{mathematica}{b}{n}
\ExplSyntaxOn
\Umathcode"03B1 = 0 \symwm "003B1
\Umathcode"03B2 = 0 \symwm "003B2
\NewDocumentCommand{\mapcommandfunction}{mm}{\cs_set:cpn {#1} {\codepoint_generate:nn{#2}{11}}}
\mapcommandfunction{alphatwo}{"03B1}
\mapcommandfunction{beta}{"03B2}
\ExplSyntaxOff
\begin{document}
$$\alphatwo\beta$$
\end{document}
(substitute your font of choice). But if I replace the code between \ExplSyntaxOn and \ExplSyntaxOff with
\Umathcode"03B1 = 0 \symwm "003B1
\Umathcode"03B2 = 0 \symwm "003B2
\NewDocumentCommand{\mapcommands}{mm}
{
\seq_set_from_clist:cc {cmds}{#1}
\seq_set_from_clist:cc {chars}{#2}
\seq_map_pairwise_function:ccN{cmds}{chars}{\mapcommandfunction}
}
\NewDocumentCommand{\mapcommandfunction}{mm}{\cs_set:cpn {#1} {\codepoint_generate:nn{#2}{11}}}
\mapcommands{alphatwo,beta}{"03B1,"03B2}
I get the error shown in the title. I have no idea what I am doing wrong or how to discover it. More specifically, I get
! Missing \endcsname inserted.
<to be read again>
\alphatwo,beta
l.27 \mapcommands{alphatwo,beta}{"03B1,"03B2}
The control sequence marked <to be read again> should
not appear between \csname and \endcsname.
How do I fix this?
\seq_set_from_clist:cc {cmds}{#1}hasccarguments, so both should be the name of a command, but you are passing inalphatwo,beta– David Carlisle Jul 23 '23 at 14:04cnand it works! Thank you! – Mike Pugh Jul 23 '23 at 14:06ccto get it to work. I'm sure I don't understand the distinction. What is going on? – Mike Pugh Jul 23 '23 at 14:21