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 12:54:55 CEST 2020
I had to do it like below:
T = [{a,1}, {length,24568}, {b,2}, {c,3}, {length, 54741}].
WithoutLength = [ {Tag, Value} || {Tag, Value} <-T, Tag/= length].
HowManyLength = length([ {Tag, Value} || {Tag, Value} <-T, Tag== length]).
Extra = lists:duplicate(HowManyLength, {length, 255}).
>NewT = [WithoutLength | Extra ].
[[{a,1},{b,2},{c,3}],{length,255},{length,255}]
Not really the expected result, yes all values of tag length are
replaced, but not in the right order.
More information about the erlang-questions
mailing list