% This file is embedded in datatool-user.pdf version 3.4.4 2026-07-31
% Example 2 Comma-Separated Lists with LaTeX3
% Label: "ex:l3clist"
% arara: pdflatex
% arara: pdfcrop
\documentclass[12pt]{article}
\pagestyle{empty}
\ExplSyntaxOn
\clist_new:N \l_my_clist
\NewDocumentCommand \createmylist { m }
{
 \clist_set:Nn \l_my_clist { #1 }
}
\NewDocumentCommand \mylistelement { m }
{
 \clist_item:Nn \l_my_clist { #1 }
}
\NewDocumentCommand \reversemylist { }
{
 \clist_reverse:N \l_my_clist
}
\NewDocumentCommand \displaymylist { }
{
 \clist_use:Nnnn \l_my_clist {~and~ } { ,~ } { ,~and~}
}
\ExplSyntaxOff 
\begin{document}
\createmylist{ant,duck,goose,zebra}
\displaymylist


Second element: \mylistelement{2}. 

\reversemylist
\displaymylist


Second element: \mylistelement{2}. 
\end{document}
