我有一个这样的 list :

[["str1","str2"],["str3","str4"],["str5","str6"]]

我需要将其转换为
["str1", "str2", "str3", "str4", "str5", "str6"]

我该怎么做呢?

问题是我正在处理字符串列表,所以当我这样做时
lists:flatten([["str1","str2"],["str3","str4"],["str5","str6"]])

我懂了
"str1str2str3str4str5str6"

但是,如果原始列表中的元素仅包含原子,那么lists:flatten将满足我的需求。如何使用字符串达到相同的目的?

最佳答案

list:append确实满足您的需求:

1> lists:append([["str1","str2"],["str3","str4"],["str5","str6"]]).
["str1","str2","str3","str4","str5","str6"]

(lists:concat做正确的事,但也威胁要进行某种类型转换。)

关于list - Erlang : flattening a list of strings,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2911420/

10-11 18:17