December 2019
Intermediate to advanced
248 pages
5h 34m
English
Since Elixir is a functional language, we should all remember that functions are data too. Sometimes using functions can offer tremendous performance wins.
For example, this is one way to store the drawing instructions for a square:
| | iex(1)> square = [ {:line, {5, 0}, {15, 0}}, |
| | {:line, {15, 0}, {15, 10}}, |
| | {:line, {15, 10}, {5, 10}}, |
| | {:line, {5, 10}, {5, 0}}] |
| | [ |
| | {:line, {5, 0}, {15, 0}}, |
| | {:line, {15, 0}, {15, 10}}, |
| | {:line, {15, 10}, {5, 10}}, |
| | {:line, {5, 10}, {5, 0}} |
| | ] |
That way works fine. Each tuple has an instruction, a beginning point and an ending point. A CAD system would have an extensive list of such instructions. The problem comes when you start to partition work across processes. When Elixir moves across ...
Read now
Unlock full access