Lists: add with list

How to define a lists:append function with a list?

I need something like

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

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

 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] 
+7
source
 [Y || X <- [[1,2,3],[a,b],[4,5,6]], Y <- X ]. 
+2
source

Source: https://habr.com/ru/post/1345447/


All Articles