How can I define lists:append
function with list comprehension?
I want something like
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With