We can use Replace
to express an almost literal translation of the problem statement:
Replace[input, n : Except[Max[input]] :> n/10., {1}]
(* {0.2, 0.3, 0.1, -0.3, -0.5, 9, 0.2, 0.6, -0.1, 0.06} *)
Why Replace
instead of /.
?
Replace
is used instead of ReplaceAll
(/.
) to ensure that the replacement rule is only applied to the level one list elements ({1}
). If we had used the /.
, then Except[Max[input]]
would match the entire list (the level zero expression), which would have ended up dividing the whole list by 10.
Why 10.
instead of 10
?
Here the approximate divisor 10.
is used in order to force all of the result values to be approximate as requested in the question. If the exact integer 10
is used instead, then the results will also be exact numbers (except for the last result, which started from the approximate input value 0.6
):
Replace[input, n : Except[Max[input]] :> n/10, {1}]
(* {1/5, 3/10, 1/10, -3/10, -1/2, 9, 1/5, 3/5, -1/10, 0.06} *)
{5,4,3,4,5}
has5
twice. $\endgroup$