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)
for i := 0 to x.count - 1 do
  if x[i] = 'foo' then
    x[i] := 'bar';
for i, v in enumerate(x):
  if v == "foo":
    x[i] = "bar"
x = ["bar" if v=="foo" else v for v in x]!{|el| el == "foo" ? "bar" : el}

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