Skip to content

Instantly share code, notes, and snippets.

@Tombarr
Created January 19, 2019 23:07
Show Gist options
  • Save Tombarr/9d934ab382fb8295d3c4ac7a994bd5f2 to your computer and use it in GitHub Desktop.
Save Tombarr/9d934ab382fb8295d3c4ac7a994bd5f2 to your computer and use it in GitHub Desktop.
Map & Reduce with assignment in Elixir
arr = [1, 2, 3, 4, 5]
arr_sqrd = Enum.map(arr, fn x -> x * x end)
arr_sqrd_sum = Enum.reduce(arr_sqrd, fn x, s -> x + s end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment