Skip to content

Commit

Permalink
Add Jekyll metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
doomspork committed Nov 26, 2015
1 parent d94f4ac commit a389090
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 102 deletions.
37 changes: 21 additions & 16 deletions lessons/advanced/concurrency.md
@@ -1,4 +1,9 @@
# Concurrency
---
layout: page
title: Concurrency
category: advanced
order: 2
---

One the selling points of Elixir is its support for concurrency. Thanks to the ErlangVM, concurrency in Elixir is easier than expected. The concurrency model replies on Actors, a contained process that communicates with other processes through message passing.

Expand All @@ -7,9 +12,9 @@ In this lesson we'll look at the concurrency modules that ship with Elixir. In
## Table of Contents

- [Processes](#processes)
- [Message Passing](#message-passing)
- [Process Linking](#process-linking)
- [Process Monitoring](#process-monitoring)
- [Message Passing](#message-passing)
- [Process Linking](#process-linking)
- [Process Monitoring](#process-monitoring)
- [Agents](#agents)
- [Tasks](#tasks)

Expand All @@ -34,7 +39,7 @@ iex> Example.add(2, 3)
```

To evaluate the function asynchronously we use `spawn/3`:

```elixir
iex> spawn(Example, :add, [2, 3])
5
Expand Down Expand Up @@ -87,12 +92,12 @@ Sometimes we don't want our linked process to crash the current one. For that w
defmodule Example do
def explode, do: exit(:kaboom)
def run do
Process.flag(:trap_exit, true)
spawn_link(Example, :explode, [])
receive do
{:EXIT, from_pid, reason} -> IO.puts "Exit reason: #{reason}"
end
Process.flag(:trap_exit, true)
spawn_link(Example, :explode, [])

receive do
{:EXIT, from_pid, reason} -> IO.puts "Exit reason: #{reason}"
end
end
end

Expand All @@ -110,10 +115,10 @@ defmodule Example do
def explode, do: exit(:kaboom)
def run do
{pid, ref} = spawn_monitor(Example, :explode, [])
receive do
{:DOWN, ref, :process, from_pid, reason} -> IO.puts "Exit reason: #{reason}"
end

receive do
{:DOWN, ref, :process, from_pid, reason} -> IO.puts "Exit reason: #{reason}"
end
end
end

Expand Down Expand Up @@ -166,4 +171,4 @@ iex> task = Task.async(Example, :double, [2000])

iex> Task.await(task)
4000
```
```
19 changes: 12 additions & 7 deletions lessons/advanced/erlang.md
@@ -1,4 +1,9 @@
# Elixir + Erlang
---
layout: page
title: Erlang Interoperability
category: advanced
order: 1
---

One of the added benefits to building on top of the ErlangVM is the plethora of existing libraries available to us. Interoperability allows us to leverage those libraries and the Erlang standard lib from our Elixir code. In this lesson we'll look at how to access functionality in the standard lib along with third-party Erlang packages.

Expand All @@ -15,11 +20,11 @@ Let's use `:timer.tc` to time execution of a given function:

```elixir
defmodule Example do
def timed(fun, args) do
{time, result} = :timer.tc(fun, args)
IO.puts "Time: #{time}ms"
IO.puts "Result: #{result}"
end
def timed(fun, args) do
{time, result} = :timer.tc(fun, args)
IO.puts "Time: #{time}ms"
IO.puts "Result: #{result}"
end
end

iex> Example.timed(fn (n) -> (n * n) * n end, [100])
Expand Down Expand Up @@ -48,4 +53,4 @@ png = :png.create(#{:size => {30, 30},
:palette => palette}),
```

That's it! Leveraging Erlang from within our Elixir applications is easy and effectively doubles the number of libraries available to us.
That's it! Leveraging Erlang from within our Elixir applications is easy and effectively doubles the number of libraries available to us.
7 changes: 6 additions & 1 deletion lessons/basics/basics.md
@@ -1,4 +1,9 @@
# Basics
---
layout: page
title: Basics
category: basic
order: 1
---

Setup, basic types and operations.

Expand Down
7 changes: 6 additions & 1 deletion lessons/basics/collections.md
@@ -1,4 +1,9 @@
# Collections
---
layout: page
title: Collections
category: basic
order: 2
---

List, tuples, keywords, maps, dicts and functional combinators.

Expand Down
39 changes: 22 additions & 17 deletions lessons/basics/composition.md
@@ -1,11 +1,16 @@
# Composition
---
layout: page
title: Composition
category: basic
order: 7
---

We know from experience its unruly to have all of our functions in the same file and scope. In this lesson we're going to cover how to group functions and define a specialized map known as a struct in order to organize our code more efficiently.

## Table of Contents

- [Modules](#modules)
- [Module attributes](#module-attributes)
- [Module attributes](#module-attributes)
- [Structs](#structs)

## Modules
Expand All @@ -14,11 +19,11 @@ Modules are the best way to organize functions into a namespace. In addition to

Let's look at a basic example:

```elixir
``` elixir
defmodule Example do
def greeting(name) do
~s(Hello #{name}.)
end
def greeting(name) do
~s(Hello #{name}.)
end
end

iex> Example.greeting "Sean"
Expand All @@ -29,13 +34,13 @@ It is possible to nest modules in Elixir, allowing you to further namespace your

```elixir
defmodule Example.Greetings do
def morning(name) do
"Good morning #{name}."
end
def morning(name) do
"Good morning #{name}."
end

def evening(name) do
"Good night #{name}."
end
def evening(name) do
"Good night #{name}."
end
end

iex> Example.Greetings.morning "Sean"
Expand All @@ -48,11 +53,11 @@ Module attributes are most commonly used as constants in Elixir. Let's take a l

```elixir
defmodule Example do
@greeting "Hello"
@greeting "Hello"

def greeting(name) do
~s(#{@greeting} #{name}.)
end
def greeting(name) do
~s(#{@greeting} #{name}.)
end
end
```

Expand All @@ -70,7 +75,7 @@ To define a struct we use `defstruct` along with a keyword list of fields and de

```elixir
defmodule Example.User do
defstruct name: "Sean", roles: []
defstruct name: "Sean", roles: []
end
```

Expand Down
7 changes: 6 additions & 1 deletion lessons/basics/control-structures.md
@@ -1,4 +1,9 @@
# Control Structures
---
layout: page
title: Control Structures
category: basic
order: 5
---

In this lesson we will look at the control structures available to us in Elixir.

Expand Down
31 changes: 18 additions & 13 deletions lessons/basics/enum.md
@@ -1,25 +1,30 @@
# Enum
---
layout: page
title: Enum
category: basic
order: 3
---

A set of algorithms for enumerating over collections.

## Table of Contents

- [Enum](#enum)
- [all?](#all?)
- [any?](#any?)
- [chunk](#chunk)
- [chunk_by](#chunk_by)
- [each](#each)
- [map](#map)
- [min](#min)
- [max](#max)
- [reduce](#reduce)
- [sort](#sort)
- [uniq](#uniq)
- [all?](#all?)
- [any?](#any?)
- [chunk](#chunk)
- [chunk_by](#chunk_by)
- [each](#each)
- [map](#map)
- [min](#min)
- [max](#max)
- [reduce](#reduce)
- [sort](#sort)
- [uniq](#uniq)

## Enum

The `Enum` module includes over one hundred functions for working with the collections we learned about in the last lesson.
The `Enum` module includes over one hundred functions for working with the collections we learned about in the last lesson.

This lesson will only cover a subset of the available functions, to see a complete set of functions visit the official [`Enum`](http://elixir-lang.org/docs/v1.0/elixir/Enum.html) docs; for lazy enumeration use the [`Stream`](http://elixir-lang.org/docs/v1.0/elixir/Stream.html) module.

Expand Down
15 changes: 10 additions & 5 deletions lessons/basics/functions.md
@@ -1,16 +1,21 @@
# Functions
---
layout: page
title: Functions
category: basic
order: 6
---

In Elixir and many functional languages, functions are first class citizens. We will learn about the types of functions in Elixir, what makes them different, and how to use them.

## Table of Contents

- [Anonymous functions](#anonymous-functions)
- [The & shorthand](#the--shorthand)
- [The & shorthand](#the--shorthand)
- [Pattern matching](#pattern-matching)
- [Named functions](#named-functions)
- [Private functions](#private-functions)
- [Guards](#guards)
- [Default arguments](#default-arguments)
- [Private functions](#private-functions)
- [Guards](#guards)
- [Default arguments](#default-arguments)

## Anonymous functions

Expand Down
7 changes: 6 additions & 1 deletion lessons/basics/mix.md
@@ -1,4 +1,9 @@
# Mix
---
layout: page
title: Mix
category: basic
order: 8
---

Before we can dive into the deeper waters of Elixir we first need to learn about mix. If you're familiar with Ruby mix is Bundler, RubyGems, and Rake combined. It's a crucial part of any Elixir project and in this lesson we're going to explore just a few of it's great features. To see all that mix has to offer run `mix help`.

Expand Down
7 changes: 6 additions & 1 deletion lessons/basics/pattern-matching.md
@@ -1,4 +1,9 @@
# Pattern Matching
---
layout: page
title: Pattern Matching
category: basic
order: 4
---

Pattern matching is a powerful part of Elixir, it allows us to match simple values, data structures, and even functions. In this lesson we will begin to see how pattern matching is used.

Expand Down
13 changes: 9 additions & 4 deletions lessons/basics/testing.md
@@ -1,13 +1,18 @@
# Testing
---
layout: page
title: Testing
category: basic
order: 9
---

Testing is an important part of developing software. In this lesson we'll look at how to test our Elixir code with ExUnit and some best practices for doing so.

## Table of Contents

- [ExTest](#extest)
- [assert](#assert)
- [refute](#refute)
- [assert_raise](#assert_raise)
- [assert](#assert)
- [refute](#refute)
- [assert_raise](#assert_raise)
- [Test Setup](#test-setup)
- [Mocking](#mocking)
- [Best Practices](#best-practices)
Expand Down

0 comments on commit a389090

Please sign in to comment.