Julia, 2321
f(x)=-x.(1-2)//abs(x.(1>x>-1))/2x Then
julia> f(f(12//1)) -12//1 p//q is julia's literal notation of rational numbers and .(1) and .(2) are short-cuts to obtain numerator and denominator. This works because Rationals are normalized with sign in the numerator.