Skip to content

Commit 956b4f9

Browse files
committed
Going to use toc instead of details.
2 parents c58e870 + a292b05 commit 956b4f9

File tree

1 file changed

+38
-35
lines changed

1 file changed

+38
-35
lines changed

README.md

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ examples. This README will serve as my notes, therefore you shouldn't take them
1111
value as the notes will make sense for me as I cherry pick a sentence or an analogy.
1212
Moreover, don't expect direct quotes, changing the sentences vocbulary helps me personally.
1313

14-
<details>
15-
<summary>Chapter 1 - The language of Macros</summary>
14+
### Contents
1615

17-
<details>
18-
<summary>What are Macros?</summary>
16+
- [Chapter 1 - The Language of Macros](#chapter-1-the-language-of-macros)
17+
- [What are Macros?](#what-are-macros)
18+
- [The Abstract Syntax Tree](#the-abstract-syntax-tree)
19+
- [Trying It All Together](#trying-it-all-together)
20+
21+
### Chapter 1 - The Language of Macros
22+
23+
#### What are Macros?
1924

2025
- Macros are code that write code.
2126
- Elixir itself is made with macros, as a result you can extend the language itself
@@ -72,36 +77,38 @@ iex> quote do: div(10, 2)
7277
In most languages, we would have to parse a string expression into something digestible by our program. With Elixir, we can access
7378
the representation of expressions directly with macros."
7479

75-
[First macro - `math.exs`](math.exs)
76-
77-
<!-- <details>
78-
<summary> [First macro - `math.exs`](math.exs) </summary>
79-
```elixir
80-
defmodule Math do
81-
@moduledoc false
82-
83-
defmacro say({:+, _, [lhs, rhs]}) do
84-
quote do
85-
lhs = unquote(lhs)
86-
rhs = unquote(rhs)
87-
result = lhs + rhs
88-
IO.puts("#{lhs} plus #{rhs} is #{result}")
89-
result
90-
end
91-
end
80+
[First macro - `math.exs`](math.exs)
9281

93-
defmacro say({:*, _, [lhs, rhs]}) do
94-
quote do
95-
lhs = unquote(lhs)
96-
rhs = unquote(rhs)
97-
result = lhs * rhs
98-
IO.puts("#{lhs} times #{rhs} is #{result}")
99-
result
100-
end
82+
<details>
83+
<summary>math.exs</summary>
84+
85+
```elixir
86+
defmodule Math do
87+
@moduledoc false
88+
89+
defmacro say({:+, _, [lhs, rhs]}) do
90+
quote do
91+
lhs = unquote(lhs)
92+
rhs = unquote(rhs)
93+
result = lhs + rhs
94+
IO.puts("#{lhs} plus #{rhs} is #{result}")
95+
result
10196
end
97+
end
98+
99+
defmacro say({:*, _, [lhs, rhs]}) do
100+
quote do
101+
lhs = unquote(lhs)
102+
rhs = unquote(rhs)
103+
result = lhs * rhs
104+
IO.puts("#{lhs} times #{rhs} is #{result}")
105+
result
102106
end
103-
```
104-
</details> -->
107+
end
108+
end
109+
```
110+
111+
</details>
105112

106113
Note when you use this in iex you need to first `c "math.exs"` then `require Math` but i've included it in [.iex.exs](.iex.exs) to save time.
107114
Automagically adding these when you open iex with `iex math.exs`.
@@ -147,7 +154,3 @@ Yes that's correct because we are dealing with ASTs not the data it represents;
147154
Much like interpolation from Ecto and the difference between `"Hello world"` and `"Hello #{world}`.
148155

149156
Back to the `math.exs`example.
150-
151-
</details>
152-
153-
</details>

0 commit comments

Comments
 (0)