I want to define a command that defined other commands. A similar problem was considered in Dynamically define commands. However, I couldn't figure out how to adapt that solution to my needs because I need the functions that I dynamically define to be able to take arguments. Consider the following example. I want to be able to use \definecommand to dynamically define both \greetp and \greete. My attempt at a solution is given below, but commented out (I used question marks where I wasn't sure what to do). I would also like my dynamically defined commands to be able to take optional arguments if possible.
\documentclass{article}
\newcommand{\greetp}[1]{hello, #1.}
\newcommand{\greete}[1]{Hello, #1!}
%\newcommand{\definecommand}[2]
%{
% \expandafter\def\csname#1p\endcsname{#2, ?.}
% \expandafter\def\csname#1e\endcsname{#2, ?!}
%}
%\definecommand{greet}{Hello}
\begin{document}
\greetp{world}
\greete{world}
\end{document}
