fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@ -0,0 +1,13 @@
---
title: Behaviours
---
## Behaviours
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/behaviours/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Comprehensions
---
## Comprehensions
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/comprehensions/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Concurrency
---
## Concurrency
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/concurrency/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Control Structures
---
## Control Structures
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/control-structures/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Custom Mix Tasks
---
## Custom Mix Tasks
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/custom-mix-tasks/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,65 @@
---
title: Data Types
---
## Data Types
In Elixir there are five basic data types: integers, floats, booleans, atoms, and strings. These data types are used to store values for later use in your program.
### Integers
An integer is a non-decimal number. Elixir has built in support for binary, octal, and hexadecimal numbers as integers.
```elixir
iex> 1337
1337
```
### Floats
A float requires a decimal and at least one digit after the decimal. Floats support 64-bit double precision and `e` for exponets.
```elixir
iex> 27e-100
27e-100
```
### Booleans
A boolean is a true or false value. In Elixir everything is truthy except for `false` and `nil`. It's important to note that booleans are a subtype of Elxir atoms (you can inspect the values in IEX to see for yourself).
```elixir
iex> true
true
iex> false
false
iex> nil
nil
```
### Atoms
An atom is a constant which value is the same as the name. Atoms are commonly used for status / errors messages inside a tuple with more information included in a string.
```elixir
iex> {:ok, "Message sent successfully"}
{:ok, "Message sent successfully"}
iex> {:error, "Message failed to send"}
{:error, "Message failed to send"}
```
### Strings
A string is UTF-8 encoded and wrapped in double quotes.
```elixir
iex> "freeCodeCamp"
"freeCodeCamp"
```
A string is also a binary, you can see a string's binary representation in Elixir by attaching `<> <<0>>` to the end of the string. A string can represent a binary, a binary can also represent a string.
```elixir
iex> "freeCodeCamp" <> <<0>>
<<102, 114, 101, 101, 67, 111, 100, 101, 67, 97, 109, 112, 0>>
```
#### More information
* [Hexdocs Atom](https://hexdocs.pm/elixir/Atom.html)
* [Hexdocs String](https://hexdocs.pm/elixir/String.html)
* [Hexdocs Integer](https://hexdocs.pm/elixir/Integer.html)
* [Hexdocs Float](https://hexdocs.pm/elixir/Float.html)

View File

@ -0,0 +1,13 @@
---
title: Debugging
---
## Debugging
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/debugging/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,50 @@
---
title: Documentation
---
## Documentation
One of the best advanced of Elixir in comparison to other programming languages is its documentation system. Elixir's documentation is created by your code comments and made into a pretty HTML Website for you to browse with ease and understand how the application works. Once you understand how to properly comment your code in Elixir, you'll be able to explain how your application works to other programmers with ease. In the examples below we show the usage of Elixir's documentation functions in a fictional webserver module.
### Inline Documentation
Inline documentation uses a `#` in front of text describing something about the code.
```elixir
def get(path) do
# This is an inline comment for documentation purposes.
"http get request response"
end
```
### Module Documentation
Module document describes the purpose of a module. Moduledocs are similar to multiline comments you would find in other programming languages.
```elixir
defmodule WebServer do
@moduledoc """
Provides a set of functions to accept and respond to HTTP requests.
This module provides the @get/1, @post/1, and @put/1 functions.
"""
end
```
### Function Documentation
Function documentation describes the purpose and usage of a single function. Functiondocs are similar to multiline comments you would find in other programming languages. It also shows examples of the function so another programmer knows what to expect.
```elixir
@doc """
Responds to a get request
## Parameters
- path: A path to the desired resource
## Examples
- iex> WebServer.get(/documentation.pdf)
"Returning documentation.pdf
- iex> WebServer.get(/downloads.html)
"Returning downloads.html"
"""
def get(path) do
"http get request response"
end
```
#### More Information:
* [ElixirSchool - Documentation](https://elixirschool.com/en/lessons/basics/documentation/)
* [ExDoc](https://github.com/elixir-lang/ex_doc)

View File

@ -0,0 +1,13 @@
---
title: Ecto
---
## Ecto
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/ecto/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Embedded Elixir
---
## Embedded Elixir
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/embedded-elixir/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,27 @@
---
title: Enumerables
---
## Enumerables (Enum)
In object oriented programming languages, you'll use a "loop" to perform the same action over and over on a piece of data, in Elixir since variables are immutable its not possible to create a tradational loop, instead Elixir and other functional programming languages rely on recursion. With recursion you'll run the same action over each item in a list without the need to mutate a variable. The Enum library built in Elixir makes this easy.
## Example
Using `Enum.map` you can run an anonymous function (function that's not inside a module) passing over each item in a list. This accomplishes the same task as a tradational loop without needing to mutate an accumulator variable.
```elixir
iex> Enum.map([1, 2, 3], fn(x) -> x * 2 end)
[2, 4, 6]
```
## Methods in the Enum Module
The Enum module has over 70 different functions to use on Enumerables, listing them all here would take up a few pages. Instead let's look at the most commonly used functions in the Enum Module.
### Enum.map
`Enum.map` runs an anonymous or captured function over a list.
```elixir
iex> Enum.map([5, 10, 15, 20], fn(x) -> x * 2 end)
[10, 20, 30, 40]
```
#### More Information:
* [elixir-lang.org | recursion](https://elixir-lang.org/getting-started/enumerables-and-streams.html)
* [hexdocs | Enum](https://hexdocs.pm/elixir/Enum.html)

View File

@ -0,0 +1,13 @@
---
title: Erlang Interoperability
---
## Erlang Interoperability
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/erlang-interoperability/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,33 @@
---
title: Erlang Term Storage
---
## Erlang Term Storage
Erlang Term Storage, normally abreviated as ETS, is an in-memory database built into OTP, it's accessible within Elixir, and is a powerful alternative to solutions like Redis when your application runs on a single node.
## Quick Start
To create an ETS table you first need to initalize a table `tableName = :ets.new(:table_otp_name, [])`, once you have initalized a table you can: insert data, lookup values, delete data, and more.
### ETS Demo in IEX
```elixir
iex(1)> myETSTable = :ets.new(:my_ets_table, [])
#Reference<0.1520230345.550371329.65846>
iex(2)> :ets.insert(myETSTable, {"favoriteWebSite", "freeCodeCamp"})
true
iex(3)> :ets.insert(myETSTable, {"favoriteProgrammingLanguage", "Elixir"})
true
iex(4)> :ets.i(myETSTable)
<1 > {<<"favoriteProgrammingLanguage">>,<<"Elixir">>}
<2 > {<<"favoriteWebSite">>,<<"freeCodeCamp">>}
EOT (q)uit (p)Digits (k)ill /Regexp -->
```
## Persistence
ETS Tables are not persistent and are destroyed once the process which owns it terminates. If you would like to store data persistently a traditional database and/or file-based storage is recommended.
## Use cases
ETS Tables are commonly used for caching data in the application, for example account data fetched from a database may be stored in an ETS Table to reduce the amount of queries to the database. Another use case is for rate limiting use of features in a web application - ETS's fast read and write speed make it great for this. ETS Tables are a powerful tool for developing highly concurrant web applications at the lowest possible hardware cost.
#### More Information:
* [elixir-lang.org | Erlang Libraries (ETS)](https://elixir-lang.org/getting-started/erlang-libraries.html#erlang-term-storage)
* [erlang.org | ETS](http://erlang.org/doc/man/ets.html)

View File

@ -0,0 +1,13 @@
---
title: Error Handling
---
## Error Handling
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/error-handling/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Executables
---
## Executables
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/executables/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Functions
---
## Functions
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/functions/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Genstage
---
## Genstage
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/genstage/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: IEX Helpers
---
## IEX Helpers
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/iex-helpers/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: IEX
---
## IEX (Interactive Mode)
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/iex/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,6 @@
---
title: Elixir
---
## Elixir
Elixir is a dynamic, functional programming language built to run on the Erlang virtual machine (BEAM). Elixir is known for being a concurrent and general purpose language that is often leveraged with the powerful Phoenix framework. This language was created by José Valim, and has been influenced by languages like Ruby, Erlang, and Closure.

View File

@ -0,0 +1,13 @@
---
title: Keyword Lists
---
## Keyword Lists
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/keyword-lists/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,37 @@
---
title: Lists
---
## Lists
In Elixir, lists are data structures comprised of values within square brackets. The values in a list can be any type.
```elixir
iex> [1, "string", true]
[1, "string", true]
```
## Immutability
Data structures in Elixir are immutable, so any operations performed on a List will return a new list, leaving the original intact.
```elixir
iex> list = [1, "string", true]
[1, "string", true]
iex> list ++ [2]
[1, "string", true, 2]
iex> list
[1, "string", true]
```
## Heads and Tails
The head (first element) of a list and the tail (remaining values) can easily accessed with the `hd/1` and `tl/1` operators.
```elixir
iex> list = [1, "string", true]
iex> hd(list)
1
iex> tl(list)
["string", true]
```
#### More Information:
* [elixir-lang.org | recursion](https://elixir-lang.org/getting-started/basic-types.html#linked-lists)
* [hexdocs | Enum](https://hexdocs.pm/elixir/List.html)

View File

@ -0,0 +1,13 @@
---
title: Maps
---
## Maps
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/maps/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Meta Programming
---
## Meta Programming
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/meta-programming/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Mix
---
## Mix
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/mix/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Mnesia
---
## Mnesia
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/mnesia/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Modules
---
## Modules
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/modules/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Operations
---
## Operations
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/operations/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: OTP Concurrency
---
## OTP Concurrency
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/otp-concurrency/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: OTP Supervisors
---
## OTP Supervisors
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/otp-supervisors/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,38 @@
---
title: Pattern Matching
---
## Pattern Matching
Pattern matching is a technique which Elixir inherits form Erlang. It is a very powerful technique that allows us to extract simpler substructures from complicated data structures like lists, tuples, maps, etc.
A match has 2 main parts, a left and a right side. The right side is a data structure of any kind. The left side attempts to match the data structure on the right side and bind any variables on the left to the respective substructure on the right. If a match is not found, the operator raises an error.
The simplest match is a lone variable on the left and any data structure on the right. This variable will match anything. For example:
`x = 12`
`x = "Hello"`
`IO.puts(x)`
You can place variables inside a structure so that you can capture a substructure. For example:
`[var_1, _unused_var, var_2] = [{"First variable"}, 25, "Second variable" ]`
`IO.puts(var_1)`
`IO.puts(var_2)`
This will store the values, `{"First variable"}` in var_1 and `"Second variable"` in var_2. There is also a special _ variable(or variables prefixed with '_') that works exactly like other variables but tells elixir, "Make sure something is here, but I don't care exactly what it is.". In the previous example, _unused_var was one such variable.
We can match more complicated patterns using this technique. For example if you want to unwrap and get a number in a tuple which is inside a list which itself is in a list, you can use the following command:
`[_, [_, {a}]] = ["Random string", [:an_atom, {24}]]`
`IO.puts(a)`
The above program generates the following result
`24`
This will bind a to 24. Other values are ignored as we are using '_'.
In pattern matching, if we use a variable on the right, its value is used. If you want to use the value of a variable on the left, you'll need to use the pin operator.
For example, if you have a variable "a" having value 25 and you want to match it with another variable "b" having value 25, then you need to enter
`a = 25`
`b = 25`
`^a = b`
The last line matches the current value of a, instead of assigning it, to the value of b. If we have a non-matching set of left and right hand side, the match operator raises an error. For example, if we try to match a tuple with a list or a list of size 2 with a list of size 3, an error will be displayed.

View File

@ -0,0 +1,45 @@
---
title: Phoenix
---
## What is Phoenix
Phoenix is a web development framework written in Elixir and created by Chris McCord. This open source framework implements the server-side MVC pattern, and has many similarities to other web frameworks like Ruby on Rails or Django for Python. Phoenix was written with an emphasis on being developer friendly, while also boasting fantastic productivity and high application performance. The Phoenix framework includes some very powerful features such as 'channels' for handling real time communication and Ecto which is a fantastic tool for ORM (Object Relational Mapping).
## Installing Phoenix
Installation of Phoenix is relatively simple, but before we can do that we'll need to ensure that Elixir, the Hex package manager, and Erlang are already working on our system. The Elixir site has a fantastic [installation guide](https://elixir-lang.org/install.html) for both Elixir and Erlang. Once these have been successfully set up, simply run:
```shell
$ mix local.hex
```
To install the Hex package manager, and then to install the Phoenix archive run:
```shell
$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
```
## Creating a Phoenix application:
1. After you install Phoenix, creating an application is simple:
```shell
$ mix phx.new <application_name>
```
2. Running this command with generate a directory structure and all the basic files needed with the *application_name* you used in the previous command. You will then be prompted to install basic dependencies for the application, so we'll say yes to that.
3. Next, we'll be prompted to change into our project directory:
```shell
$ cd <application_name>
```
4. By default, Phoenix assumes that we'll be using PostgreSQL for our application with a username and password of 'postgres'. If that isn't the case, you'll need to change your configuration - otherwise all we need to do is create our database:
```shell
$ mix ecto.create
```
5. Finally, we'll start our server up:
```shell
$ mix phx.server
```
6. Now, hop in your browser and navigate to localhost:4000 and see the welcome page! Congratulations, you've got a working Phoenix application.

View File

@ -0,0 +1,13 @@
---
title: Pipe Operator
---
## Pipe Operator
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/pipe-operator/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Plug
---
## Plug
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/plug/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Protocols
---
## Protocols
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/protocols/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Sigils
---
## Sigils
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/sigils/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,13 @@
---
title: Specifications and Types
---
## Specifications and Types
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/specifications-and-types/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,32 @@
---
title: Strings
---
## Strings
Strings in Elixir are wrapped with double-quotes, while Character Lists are single-quoted. They are UTF-8 encoded binaries.
```elixir
iex> "Hello world!"
"Hello world!"
```
String Interpolation is possible in Elixir with an octothorp followed by curly braces.
```elixir
iex> variable = "world!"
"world!"
iex> "Hello #{variable}"
"Hello world!"
```
The String module contains many helpful built in functions based on the Unicode standard.
```elixir
iex> example = "string"
"string"
iex> String.capitalize(example)
"String"
iex> String.duplicate(example, 2)
"stringstring"
```
#### More Information:
* [elixir-lang.org | recursion](https://elixir-lang.org/getting-started/basic-types.html#strings)
* [hexdocs | Enum](https://hexdocs.pm/elixir/String.html)

View File

@ -0,0 +1,13 @@
---
title: Testing
---
## Testing
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/testing/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->

View File

@ -0,0 +1,33 @@
---
title: Tuples
---
## Tuples
In Elixir, tuples are a data-structure that can hold any value or mixture of types. Tuples are defined by curly braces, and their indexes start from 0. Because tuples are stored contiguously in memory, getting data from them is a very quick operation.
```elixir
iex> tuple = {:atom, "string"}
{:atom, "string"}
iex> elem(tuple, 0)
:atom
```
## Immutability
Tuples in Elixir are an immutable, so making modifications will return an entirely new tuple - saving the original in memory.
```elixir
iex> tuple = {:atom, "string"}
{:atom, "string"}
iex> put_elem(tuple, 1, true)
{:atom, true}
iex> tuple
{:atom, "string"}
```
## Pattern Matching
The most common use of tuples in Elixir is as a return for a function. For example: `{:ok, "Hello World\n"}`
This is a very helpful, as it enables the use of Pattern Matching to handle these returns.
#### More Information:
* [elixir-lang.org | recursion](https://elixir-lang.org/getting-started/basic-types.html#tuples)
* [hexdocs | Enum](https://hexdocs.pm/elixir/Tuple.html)

View File

@ -0,0 +1,13 @@
---
title: Umbrella Projects
---
## Umbrella Projects
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/elixir/umbrella-projects/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
#### More Information:
<!-- Please add any articles you think might be helpful to read before writing the article -->