I am trying to write a macro that selects an item from a comma separated list,
`\select{2}{A,B,C,D,E}` results in `B`. I am using the `xfor` package to process the list, but would try `etoolbox` if that offered a better solution. Now for the problem: the macro works fine for plain text, however if the item is a number, I get an unclosed `\ifnum`.

```

! Incomplete \ifnum; all text was ignored after line 29.

                \fi 

```

Here is the minimal example

```
\documentclass{article}
\usepackage{xfor}
\usepackage{biblatex}

\makeatletter
\newcount\select@count
\newcount\select@i
\newcommand\select[2]{%
    \select@i=1\select@count=0%
    \@for\@@select@item:={#2}\do{\advance\select@count by1}%
    \ifnum#1>\select@count??\else%
    \@for\@@select@item:={#2}\do{%
      \advance\select@i by1%
      \ifnum#1<1??\@endfortrue\fi%
      \ifnum\select@i=#1\@@select@item\@endfortrue\fi%
    }%
  \fi%
}
\makeatother

\begin{document}
\begin{itemize}
  \item \verb+\select{0}{A,B,C,D,E}+ gives \select{0}{A,B,C,D,E}
  \item \verb+\select{1}{A,B,C,D,E}+ gives \select{1}{A,B,C,D,E}
  \item \verb+\select{2}{A,B,C,D,E}+ gives \select{2}{A,B,C,D,E}
  \item \verb+\select{5}{A,B,C,D,E}+ gives \select{5}{A,B,C,D,E}
  \item \verb+\select{10}{A,B,C,D,E}+ gives \select{10}{A,B,C,D,E}
%  these do not work
%  \item \verb+\select{1}{1,2,3,4,5}+ gives \select{1}{1,2,3,4,5}
%  \item \verb+\select{2}{1,2,3,4,5}+ gives \select{2}{1,2,3,4,5}
\end{document}

```

Any thought on why it fails with numbers? Do I need to protect my list?