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

Bulat Ziganshin bulat.ziganshin at gmail.com
Thu Oct 22 05:28:35 EDT 2009

Hello zaxis,

Thursday, October 22, 2009, 1:03:21 PM, you wrote:

> Is [(1,1),(2,2),(3,3)] been regarded as a hash ? If not, what is the best
> way to change it to [(1,1),(2,2222),(3,3)] in function `f` ?

f = map (\x@(a,b) -> if a==2 then (a,2222) else x)


f xs = [(a, if a==2 then 2222 else b) | (a,b) <- xs]

but anyway, modifying one value inside complex datastructure is not FP
way. you should consider writing a function that maps your entire
input data to output one

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list