From 3114a38a033aa38a37df1890e6958e1d53200159 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Sun, 14 Feb 2016 11:21:29 -0600 Subject: [PATCH] Add Expose Internal Representation as an elixir til --- README.md | 3 ++- elixir/expose-internal-representation.md | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 elixir/expose-internal-representation.md diff --git a/README.md b/README.md index 9dc5a74..2d7afa1 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/). -_333 TILs and counting..._ +_334 TILs and counting..._ --- @@ -66,6 +66,7 @@ _333 TILs and counting..._ ### Elixir - [Append To A Keyword List](elixir/append-to-a-keyword-list.md) +- [Expose Internal Representation](elixir/expose-internal-representation.md) - [Replace Duplicates In A Keyword List](elixir/replace-duplicates-in-a-keyword-list.md) ### Git diff --git a/elixir/expose-internal-representation.md b/elixir/expose-internal-representation.md new file mode 100644 index 0000000..452da8d --- /dev/null +++ b/elixir/expose-internal-representation.md @@ -0,0 +1,16 @@ +# Expose Internal Representation + +Elixir is a language that has strong support for metaprogramming. It +provides easy access to an internal representation of the code in the form +of an Abstract Syntax Tree (AST) using maps and keyword lists. The `quote` +function is used to expose this internal representation. + +```elixir +> quote do: 2 * 2 +{:*, [context: Elixir, import: Kernel], [2, 2]} +> quote do: 2 * 2 == 4 +{:==, [context: Elixir, import: Kernel], + [{:*, [context: Elixir, import: Kernel], [2, 2]}, 4]} +``` + +[source](http://elixir-lang.org/getting-started/meta/quote-and-unquote.html)