Deduct "New List" with "new Value" only for some "specific Tag", from Old List, using "List Comprehension".
Papa Tana
papa.tana101@REDACTED
Sun Jul 19 08:55:01 CEST 2020
Hi All,
I have a list "TV" Containing some {Tag, Value} as below:
TV = [{a,1}, {off,1234}, {d,4}, {e,5}, {off,5678}].
I would like to replace all tag name "off" in this list, to a new value = 255.
Wanted result:
[{a,1}, {off,255}, {d,4}, {e,5}, {off,255}].
I can only get the below, I don't know how to change them:
[ {Tag1, Value1} || {Tag1, Value1} <- TV, Tag1/=off].
[ {Tag1, Value1} || {Tag1, Value1} <- TV, Tag1==off].
Any advice please?
Thanks,
Best Regards,
More information about the erlang-questions
mailing list