You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crash-course.markdown
+4-45Lines changed: 4 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -167,7 +167,7 @@ Invoking a function from a module uses different syntax. In Erlang, you would wr
167
167
lists:last([1, 2]).
168
168
```
169
169
170
-
to invoke the `last` function from the `List` module. In Elixir, use the dot `.` in place of the colon `:`
170
+
to invoke the `last` function from the `lists` module. In Elixir, use the dot `.` in place of the colon `:`
171
171
172
172
```elixir
173
173
List.last([1, 2])
@@ -312,7 +312,7 @@ kw[:another_key]
312
312
313
313
### Maps
314
314
315
-
Erlang R17 introduced maps, a key-value store, with no ordering. Keys and values can be any term. Creating, updating and matching maps in both languages is shown below:
315
+
Maps are key-value pairs with no ordering. Keys and values can be any term. Creating, updating and matching maps in both languages is shown below:
316
316
317
317
**Erlang**
318
318
@@ -361,18 +361,6 @@ Regex.run(~r/abc\s/, "abc ")
361
361
#=> ["abc "]
362
362
```
363
363
364
-
Regexes are also supported in heredocs, which is convenient when defining multiline regexes:
365
-
366
-
```elixir
367
-
Regex.regex?(~r"""
368
-
This is a regex
369
-
spanning several
370
-
lines.
371
-
""")
372
-
#=> true
373
-
```
374
-
375
-
376
364
## Modules
377
365
378
366
Each Erlang module lives in its own file which has the following structure:
[This chapter][3] from the Erlang book provides a detailed description of pattern matching and function syntax in Erlang. Here, I'm briefly covering the main points and provide sample code both in Erlang and Elixir.
443
+
[This chapter][3] from the Erlang book provides a detailed description of pattern matching and function syntax in Erlang. Here, we briefly cover the main points and provide sample code both in Erlang and Elixir.
Elixir compiles into BEAM byte code (via Erlang Abstract Format). This means that Elixir code can be called from Erlang and vice versa, without the need to write any bindings. All Elixir modules start with the `Elixir.` prefix followed by the regular Elixir name. For example, here is how to use the UTF-8 aware `String` downcase from Elixir in Erlang:
@@ -848,33 +834,6 @@ downcase(Bin) ->
848
834
'Elixir.String':downcase(Bin).
849
835
```
850
836
851
-
### Rebar integration
852
-
853
-
If you are using rebar, you should be able to include Elixir git repository as a dependency:
854
-
855
-
https://github.com/elixir-lang/elixir.git
856
-
857
-
Elixir is structured similar to Erlang's OTP. It is divided into applications that are placed inside the `lib` directory, as seen in its [source code repository](https://github.com/elixir-lang/elixir). Since rebar does not recognize such structure, we need to explicitly add to our `rebar.config` which Elixir apps we want to use, for example:
858
-
859
-
```erlang
860
-
{lib_dirs, [
861
-
"deps/elixir/lib"
862
-
]}.
863
-
```
864
-
865
-
This should be enough to invoke Elixir functions straight from your Erlang code. If you are also going to write Elixir code, you can [install Elixir's rebar plugin for automatic compilation](https://github.com/yrashk/rebar_elixir_plugin).
866
-
867
-
### Manual integration
868
-
869
-
If you are not using rebar, the easiest approach to use Elixir in your existing Erlang software is to install Elixir using one of the different ways specified in the [Getting Started guide](https://hexdocs.pm/elixir/introduction.html) and add the `lib` directory in your checkout to `ERL_LIBS`.
870
-
871
-
872
837
## Further reading
873
838
874
-
Erlang's official documentation site has a nice [collection][4] of programming examples. It can be a good exercise to translate them into Elixir.
875
-
876
-
Elixir also provides a [Getting Started guide][6] and has [documentation available online][7].
Both programming languages have plenty of resources available to dig deeper. Check out their respective websites ([Elixir](https://elixir-lang.org) and [Erlang](https://www.erlang.org)) for more information.
Copy file name to clipboardExpand all lines: index.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -196,7 +196,7 @@ <h4>Erlang compatible</h4>
196
196
<<192,223,75,115,...>>
197
197
{% endhighlight %}
198
198
199
-
<p>To learn more about Elixir, check our <ahref="https://hexdocs.pm/elixir/introduction.html">Getting Started guide</a>. We also have <ahref="/docs.html">online documentation available</a> and a <ahref="/crash-course.html">Crash Course for Erlang developers</a>.</p>
199
+
<p>To learn more about Elixir, check our <ahref="https://hexdocs.pm/elixir/introduction.html">Getting Started guide</a>.</p>
0 commit comments