[Haskell-cafe] How can i safely change the value of specified key ?

minh thu noteed at gmail.com
Thu Oct 22 05:34:21 EDT 2009

2009/10/22 zaxis <z_axis at 163.com>:
>>>f xs = (2,2222) : filter ((/=2) . fst) xs
> It works but not general as `f` still needs to change other value according
> to the "KEY".
> Maybe Data.List will supply what i need.

I don't think Data.List has what you want as-is. The above code is
generalized simply:
replace k v xs = (k,v) : filter ((/=v) . fst) xs


More information about the Haskell-Cafe mailing list