According to this theorem:
And an example afterwards is:
Now here $f(x)$ is $x$ and its domain is all real numbers greater or equal to zero, $g(x)$ is $\frac{x}{2}$ and its domain is all real numbers less than or equal to zero, this means that:
$f: [-\infty,0] --> [-\infty,0]$
so in the statement of the theorem, A is $[-\infty,0]$ and Y is also $[-\infty,0]$
But g has a different range which is $[0, \infty]$ which is also Y in the theorem
so Y is both $[-\infty,0]$ and $[0, \infty]$
Then $h$ : R ---> Y
Which Y? Maybe I'm not understanding the notation ' ---> ' in the function definition?


In the example you have $X = Y = \mathbb R, A = (-\infty,0], B = [0,\infty)$.