diff --git a/README.md b/README.md index e27834e..7888183 100644 --- a/README.md +++ b/README.md @@ -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 smart people at [Hashrocket](http://hashrocket.com/). -_448 TILs and counting..._ +_449 TILs and counting..._ --- @@ -91,6 +91,7 @@ _448 TILs and counting..._ - [Pattern Matching In Anonymous Functions](elixir/pattern-matching-in-anonymous-functions.md) - [Quitting IEx](elixir/quitting-iex.md) - [Replace Duplicates In A Keyword List](elixir/replace-duplicates-in-a-keyword-list.md) +- [Reversing A List](elixir/reversing-a-list.md) - [String Interpolation With Just About Anything](elixir/string-interpolation-with-just-about-anything.md) - [Word Lists For Atoms](elixir/word-lists-for-atoms.md) diff --git a/elixir/reversing-a-list.md b/elixir/reversing-a-list.md new file mode 100644 index 0000000..845d43e --- /dev/null +++ b/elixir/reversing-a-list.md @@ -0,0 +1,19 @@ +# Reversing A List + +To efficiently work with and _transform_ lists in Elixir, you will likely +need utilize a list reversing function from time to time. Your best bet is +to reach for the Erlang implementation which is available as part of the +`lists` module. + +Here are a couple examples of how to use it: + +```elixir +> :lists.reverse([1,2,3]) +[3, 2, 1] +> :lists.reverse([1, :a, true, "what", 5]) +[5, "what", true, :a, 1] +``` + +Note: though I said "_transform_ lists" above, what is actually going on is +that a new version of the list representing my transformation is being +created, per Elixir's functional nature.