Do & Don’t — Length of Range — Elixir

Malreddy Ankanna
2 min readDec 18, 2018

Calculating the length of range

iex> range = 1..100000000

DON’T ❌

iex> range |> Enum.to_list |> length
100000000

It takes a few seconds to give you the result and it’s a bad idea.

DO ✔️

The following code statements would results in no time.

--

--

Malreddy Ankanna

Programmer & Writer, I write about coding, thoughts, ideas, personal musings, technical articles, and tutorials.https://bio.link/blackode