开发者

lists:append with list comprehensions

How can I define lists:append function with list comprehension?

I want something li开发者_Go百科ke

1> append([[1, 2, 3], [a, b], [4, 5, 6]]).
[1,2,3,a,b,4,5,6]


Remember that you can use elements from a generator in a later generator in the same list comprehension!

1> Lists = [[1, 2, 3], [a, b], [4, 5, 6]].
[[1,2,3],[a,b],[4,5,6]]
2> [N || L <- Lists, N <- L].             
[1,2,3,a,b,4,5,6]


[Y || X <- [[1,2,3],[a,b],[4,5,6]], Y <- X ].
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜