Subtract value from list
I would use Clip
:
Clip[{2,3,5,4,6,7,3,7,5,4}, {5, Infinity}, {0, 0}]
{0, 0, 5, 0, 6, 7, 0, 7, 5, 0}
You could also use Threshold
list = {2, 3, 5, 4, 6, 7, 3, 7, 5, 4};
value = 5;
For the case of integers
Threshold[list, value - 1]
(* {0, 0, 5, 0, 6, 7, 0, 7, 5, 0} *)
EDIT: Comparative timings
kumar[list_, value_] := UnitStep[list - value] list
hanlon[list_, value_] := Threshold[list, value - 1]
alan[list_, value_] := If[# < value, 0, #] & /@ list
woll[list_, value_] := Clip[list, {value, ∞}, {0, 0}]
nasser[list_, value_] :=
ReplacePart[list, Position[list, x_ /; x - value < 0] -> 0]
{#, RepeatedTiming[Do[temp = #[list, value], {10000}]; temp]} & /@ {hanlon,
woll, alan, kumar, nasser} // Grid
Using UnitStep
UnitStep[list - value] list
{0, 0, 5, 0, 6, 7, 0, 7, 5, 0}