J - 7 3
Max of number and inverse (3)
>.-
When assigned to a function: take the maximum between the negative and the number, using a hook so: (f g) y = y f g y
f=:>.-
f _4 5 _1 0
4 5 1 0
The older version:root of the square (5 or 4)
]&.*: _4 5 _1 0
4 5 1 0
NB. or if an expression is good enough:
%:*: _4 5 _1 0
4 5 1 0
Negate if number smaller than its negative (7)
-^:(<-)
Takes the inverse (the inverse is bigger than the number itself) times.
Would loosely translate to:
if -num > num then
num= -num
end