Erlang : Is there a function to remove all nested elements from a list?

StackOverflow https://stackoverflow.com/questions/22131315

  •  19-10-2022
  •  | 
  •  

문제

I have this kind of list:

[[[[{a,2},{s,w}],{e,1}],{d,l}]]

Is there a function that will remove all of the tuples so they are all on the same level? Like:

[{a,2},{s,w},{e,1},{d,l}]

Thanks

도움이 되었습니까?

해결책

You can use flatten/1 from the lists module.

lists:flatten([[[[{a,2},{s,w}],{e,1}],{d,l}]]).
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top