mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Add Reversing A List - Part 2 as an elixir til
This commit is contained in:
@@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
|
|||||||
warrant a full blog post. These are mostly things I learn by pairing with
|
warrant a full blog post. These are mostly things I learn by pairing with
|
||||||
smart people at [Hashrocket](http://hashrocket.com/).
|
smart people at [Hashrocket](http://hashrocket.com/).
|
||||||
|
|
||||||
_488 TILs and counting..._
|
_489 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -101,6 +101,7 @@ _488 TILs and counting..._
|
|||||||
- [Quitting IEx](elixir/quitting-iex.md)
|
- [Quitting IEx](elixir/quitting-iex.md)
|
||||||
- [Replace Duplicates In A Keyword List](elixir/replace-duplicates-in-a-keyword-list.md)
|
- [Replace Duplicates In A Keyword List](elixir/replace-duplicates-in-a-keyword-list.md)
|
||||||
- [Reversing A List](elixir/reversing-a-list.md)
|
- [Reversing A List](elixir/reversing-a-list.md)
|
||||||
|
- [Reversing A List - Part 2](elixir/reversing-a-list-part-2.md)
|
||||||
- [Root Directory Of A Project](elixir/root-directory-of-a-project.md)
|
- [Root Directory Of A Project](elixir/root-directory-of-a-project.md)
|
||||||
- [Round Floats To Integers](elixir/round-floats-to-integers.md)
|
- [Round Floats To Integers](elixir/round-floats-to-integers.md)
|
||||||
- [Run ExUnit Tests In A Deterministic Order](elixir/run-exunit-tests-in-a-deterministic-order.md)
|
- [Run ExUnit Tests In A Deterministic Order](elixir/run-exunit-tests-in-a-deterministic-order.md)
|
||||||
|
|||||||
13
elixir/reversing-a-list-part-2.md
Normal file
13
elixir/reversing-a-list-part-2.md
Normal 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]
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user