I want to define a new command such that when a first and only argument is given it does one thing and when a second argument is given it expands the first argument. The idea is to replicate the probability function. One argument is for probability distribution and two arguments are for conditional probability distribution. I really don't know how to do it.
The (completed) following code
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\newcommand{\PP}[2]{???}
\begin{document}
$\PP{X}$
$\PP{X}{Y}$
\end{document}
should print
\mathbb{P}{\left({X}\right)}
\mathbb{P}{\left({X}\middle|{Y}\right)}
I wouldn't like to have an optional argument because it would affect the order and readability of the code. I mean, I prefer \PP{X}{Y} over \PP[Y][X].
Could you please help me?
Thanks



\PP{X,Y}, so that you would only ever need a single argument? – Steven B. Segletes Sep 15 '20 at 19:43\PP[X]{Y}. Then you'd just need to check if the optional value is empty or not. – Teepeemm Sep 15 '20 at 19:48