Translated code that calls Replace_elements is incorrect in cases where the removal of elements cannot be done in place.
Make sure the result is assigned.