Skip to content

Latest commit

 

History

History
13 lines (11 loc) · 413 Bytes

reversing-a-list-part-2.md

File metadata and controls

13 lines (11 loc) · 413 Bytes

Reversing A List - Part 2

In Reversing A List, I showed how Erlang's :lists.reverse() function could be used to reverse a list. Since then, Elixir now has a built-in function for reversing lists. In fact, it works with anything that implements the Enumerable protocol.

> Enum.reverse([1,2,3,4,5])
[5, 4, 3, 2, 1]
> Enum.reverse(%{a: 1, b: 2, c: 3})
[c: 3, b: 2, a: 1]