In a list lst
I want to change all values > 255 to 255. Why is this code not working?
lst= {336, 315, 395, 337, 411, 309, 408, 338, 576, 377, 508, 386, 545, \
477, 453, 424, 425, 286, 363, 248, 298, 268, 221, 162, 184, 121, 164, \
124, 161, 109, 165, 150, 183, 111, 154, 132, 136, 88, 123, 388, 387, \
382, 375, 340, 325, 374, 324, 372, 295, 398, 361, 547, 418, 483, 381, \
517, 465, 454, 432, 414, 288, 342, 241, 281, 261, 218, 172, 165, 127, \
532, 392, 397, 345, 403, 375, 400, 342, ...}
inf = Flatten@Position[lst, _?(# > 255 &)];
ReplacePart[lst, inf -> 255]
It seems that it doesn't effect the list at all. Thanks a lot for opening my eyes...
ReplacePart[lst, Thread[inf -> 255]]
$\endgroup$