Skip to main content
Fix
Source Link
Moritz Schauer
  • 1.8k
  • 12
  • 19

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.

Julia, 23

f(x)=-x.(2)//abs(x.(1)) 

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.

Julia, 21

f(x)=(1-2(1>x>-1))/2x 

Then

julia> f(f(12//1)) -12//1 

p//q is julia's literal notation of rational numbers.

Post Undeleted by Moritz Schauer
Post Deleted by Moritz Schauer
Source Link
Moritz Schauer
  • 1.8k
  • 12
  • 19

Julia, 23

f(x)=-x.(2)//abs(x.(1)) 

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.