Honestly, these three lines of code should be all you need to show somebody the immense power of Elixir.

With just one function call, you can parallelise a task over all available CPUs. One!

# Counts the characters in each word and returns the overall sum.
#
# Task.async_stream/3 runs as many tasks in parallel as you have schedulers.
# This defaults to the number of available CPUs. Each task applies
# the function to only one element and returns the result.
["elixir", "is", "great"]
|> Task.async_stream(fn word -> String.length(word) end)
|> Enum.reduce(0, fn {:ok, count}, acc -> count + acc end)
continue reading on x.com

⚠️ This post links to an external website. ⚠️