fun abs r = if r > 0 then r else ~r; (* absolute value -- ?what type, int or real? *)