Logo

Programming-Idioms

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

Idiom #254 Replace value in list

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

[case Elem of "foo" -> "bar"; _ -> Elem end || Elem <- X].
(replace {"foo" "bar"} x)

New implementation...