This language bar is your friend. Select your favorite languages!

Idiom #254 Replace value in list

Replace all occurrences of "foo" with "bar" in the string list x

(replace {"foo" "bar"} x)
replaced = map (\e -> if e == "foo" then "bar" else e) x
x = => e === 'foo' ? 'bar' : e);
for i := 0 to x.count - 1 do
  if x[i] = 'foo' then
    x[i] := 'bar';
x = ["bar" if v=="foo" else v for v in x]
for i, v in enumerate(x):
  if v == "foo":
    x[i] = "bar"!{|el| el == "foo" ? "bar" : el}

Do you know the best way to do this in your language ?
New implementation...