My problem is I have a list and want to remove some strings in it. but when I remove the first time it's OK. but the second time, it removes the string but bring back the first one. do you know how I can avoid this? thank you
Prelude Data.List Data.Char> x = ["ab","cd","ef","gh"]
Prelude Data.List Data.Char> delete "ab" x
["cd","ef","gh"]
Prelude Data.List Data.Char> delete "cd" x
["ab","ef","gh"]
!!Here the "ab"
came back and I don't want this!! thanks
See ''How to "think functional"'' here. In short, x
is the same x
; delete "abc" x
returns new value, it does not change the existing x
.
If you want to refer to this new value, give it a new name, like this:
> x = ["ab","cd","ef","gh"]
> x2 = delete "ab" x
> delete "cd" x2
["ef","gh"]