What would be an efficient way to replace contiguous identical values in a list elements by another given value, but only if the the contiguous sequence runs for more than a certain number of elements (eg : more or equals to 5)
Example:
["red"; "red"; "blue"; "green"; "green"; "red"; "red" ; "red"; "red"; "red"; "red"; "yellow"; "white"; "white"; "red"; "white"; "white"]
should become:
["red"; "red"; "blue"; "green"; "green"; "ignore"; "ignore" ; "ignore"; "ignore"; "ignore"; "ignore"; "yellow"; "white"; "white"; "red"; "white"; "white"]
Any idea?