Logo

Programming-Idioms

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

Idiom #254 Replace value in list

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

uses classes;
for i := 0 to x.count - 1 do
  if x[i] = 'foo' then
    x[i] := 'bar';
(replace {"foo" "bar"} x)

New implementation...