mapConserve

trait List[A] {
  def mapConserve[B >: A](f: (A) => B): List[B]
}

mapConserve applies the function f to each element of this List and returns it untouched if every transformed element is equal (in terms of eq) to the element it was retrieved from.

If at least one transformed element is not equal (in terms of eq) to its source element then this function creates a new List built from the transformed results.