Erlang provides Lists Comprehensions to build or modify lists. List Comprehensions in Erlang are about building sets from other sets.
LC is based off the idea of set notation, set notation basically tells you how to build a set by specifying properties its members must satisfy.
In the post Handling lists with erlang – part 1 : start using lists I have shown how to build a list of the even integers number less than 100 using the seq function.
With LC we are going to define the set in the following way:
We want all the X contained in N (Integer numbers) such that X < 100 and the remainder of the division by 2 is 0. So we can write the code: ```1> EvenNumbers = [X || X <- lists:seq(0, 100), X rem 2 == 0]. [0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40, 42,44,46,48,50,52,54,56|...] 2> ```

Imagine you want to represent the following line in the cartesian plane using positive integers:
y = x +1;

It is very simple using List Comprehensions:
``` 12> [{X, Y} || X <- lists:seq(0, 100), Y <- lists:seq(0, 100), Y-X==1]. [{0,1}, {1,2}, {2,3}, {3,4}, {4,5}, {5,6}, {6,7}, {7,8}, {8,9}, {9,10}, {10,11}, {11,12}, {12,13}, {13,14}, {14,15}, {15,16}, {16,17}, {17,18}, {18,19}, {19,20}, {20,21}, {21,22}, {22,23}, {23,24}, {24,25}, {25,26}, {26,27}, {27,...}, {...}|...] 13> ```

Now if you want to represent the following parabola.
Y = X^2 + X + 1;

with X in [-10, 10] and Y in [-10, 100].
``` [{X, Y} || X <- lists:seq(-10, 10), Y <- lists:seq(-10, 100), Y-X*X-X==1]. [{-10,91}, {-9,73}, {-8,57}, {-7,43}, {-6,31}, {-5,21}, {-4,13}, {-3,7}, {-2,3}, {-1,1}, {0,1}, {1,3}, {2,7}, {3,13}, {4,21}, {5,31}, {6,43}, {7,57}, {8,73}, {9,91}]```

Gg1