Is there an `\edef` version of `\NewDocumentCommand` or `\newcommand` with optional arguments?
Not sure what this would be useful for.
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\bunchdefine}{m}
{
\clist_map_inline:nn { #1 }
{
\exp_args:Nc \NewDocumentCommand { ##1 } { } { ##1 }
}
}
\ExplSyntaxOff
\bunchdefine{one,two}
\begin{document}
\one
\two
\end{document}
As you see, there is no \x
here, but just #1
(doubled #
because it's in the body of a definition) that represents the current item.
The mysterious \exp_args:Nc
means: skip over the next token and form a control sequence name with the braced argument that follows, so it's essentially the same as
\expandafter\NewDocumentCommand\csname##1\endcsname
but easier.