Is this possible?

```
\documentclass{article}
\usepackage{xparse,amsmath}
\NewDocumentCommand{\myfunc}{O{} m O{+} m}{
    % some dark sorcery
}
\begin{document}
\[
\myfunc[a]{x,y}{2,3} % should return ax^2 + ay^3
\]
\end{document}

```