Question: Inverse of a piecewise function

I try to make the inverse of a one to one piecewise function, but the solve command gives a function of lists. How can I avoid this?

restart;
f := x -> piecewise( x<=1, (x-1)/2, x<2, -3*(x-1)+3, 2*(x-2)+3 ):
solve( f(x)=y, x ): g := unapply(%,y): lprint(g(x));
piecewise(x <= 0, [1+2*x], x < 3, [2-(1/3)*x], 3 <= x, [1/2+(1/2)*x])

Please Wait...