1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-06 08:38:01 +00:00

Add Reversing A List - Part 2 as an elixir til

This commit is contained in:
jbranchaud
2016-11-26 13:33:23 -06:00
parent 4b57eaa04b
commit 31ebf4e878
2 changed files with 15 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
# Reversing A List - Part 2
In [Reversing A List](reversing-a-list.md), 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.
```elixir
> 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]
```