Here's a quick expl3
(well, xparse
method, for checking whether the second argument is in the list. However, the clist-variable would be in a command macro, usually,otherwise you would know if it is in the list.
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\IsMember}{mm+m+m}{%
\clist_set:Nx \l_tmpa_clist {#1}
\clist_if_in:NnTF \l_tmpa_clist {#2} {#3} {#4}
}
\ExplSyntaxOff
\newcommand{\foo}{%
elem1,elem2,elem3%
}
\begin{document}
\IsMember{\foo}{elem1}{true}{false}
\IsMember{\foo}{elem5}{true}{false}
\end{document}