Skip to content

Commit

Permalink
fixes markdown #21
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcarlisle committed Feb 10, 2017
1 parent 9f8bd8f commit c7cda42
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions README.md
Expand Up @@ -408,7 +408,7 @@ To get started with your first Elixir project you need to make use of the [Mix](

To generate a new project follow these steps:

1. Initialise a project by typing the following command in your terminal, replacing [project_name] with the name of your project:
#### Initialise a project by typing the following command in your terminal, replacing [project_name] with the name of your project:

```bash
> mix new [project_name]
Expand Down Expand Up @@ -448,8 +448,8 @@ generated a few files for us that are specific to our project:
- `lib/animals.ex`
- `test/animals_test.ex`

2. Open up the `animals.ex` file in the lib directory. You should already
see some `hello-world` boilerplate like this:
#### Open up the `animals.ex` file in the lib directory. You should already see some `hello-world` boilerplate like this:

```elixir
defmodule Animals do
@moduledoc """
Expand All @@ -475,26 +475,22 @@ that prints out a `:world` atom when called. It's also added boilerplate for
module and function documentation. (*we will go into more detail about
documentation later*)

3. Let's test out the boilerplate code. In your project directory type the following
command:

#### Let's test out the boilerplate code. In your project directory type the following command:
```bash
> iex -S mix
```
What this basically means is, "Start the elixir interactive terminal and compile
with the context of my current project". This allows you to access modules and
functions created within the file tree.

functions created within the file tree.
Call the `hello-world` function given to us by Elixir. It should print out the
`:world` atom to the command line:

```bash
> Animals.hello
# :world
```

4. Let's start to create our own methods in the `Animals` module. Replace the
`hello-world` method with the following:
#### Let's start to create our own methods in the `Animals` module. Replace the `hello-world` method with the following:

```elixir
@doc """
create_zoo returns a list of zoo animals
Expand All @@ -520,9 +516,7 @@ Now we will have access to the `create_zoo` method. Try it out in the command li
# ["lion", "tiger", "gorilla", "elephant", "monkey", "giraffe"]
```

4. Let's extend the `Animals` module. Let's say that you're visiting the zoo but
you can't decide which order to view the animals. We can create a `randomise` function
that takes a list of animals and returns a new list with a random order:
#### Let's extend the `Animals` module. Let's say that you're visiting the zoo but you can't decide which order to view the animals. We can create a `randomise` function that takes a list of animals and returns a new list with a random order:

```elixir
@doc """
Expand All @@ -544,8 +538,7 @@ Note we are making use of a pre-built module called `Enum` which has a list of
methods that you can use on enumerables such as lists. Documentation for `Enum`
methods can be found [here](https://hexdocs.pm/elixir/Enum.html)

5. Let's add another method to the `Animals` module. Let's say that we want to
find out if our zoo contains an animal:
#### Let's add another method to the `Animals` module. Let's say that we want to find out if our zoo contains an animal:

```elixir
@doc """
Expand All @@ -565,8 +558,7 @@ end
**NOTE: It's convention when writing a function that returns a boolean to add a question
mark after the name of the method.**

6. Pattern matching example: Let's create a function that takes a list of animals and
the number of animals that you'd like to see and then returns a list of animals.
#### Pattern matching example: Let's create a function that takes a list of animals and the number of animals that you'd like to see and then returns a list of animals.

```elixir
@doc """
Expand All @@ -587,8 +579,7 @@ def see_animals(zoo, count) do
end
```

7. What if we want to save our list of animals to a file? Let's write a function
that will do this for us:
#### What if we want to save our list of animals to a file? Let's write a function that will do this for us:

```elixir
@doc """
Expand Down Expand Up @@ -620,7 +611,7 @@ is what gets returned for our animals file:

`�lmlionmtigermgorillamelephantmmonkeymgiraffej`

8. Now let's write a function that will allow us to access that information again:
#### Now let's write a function that will allow us to access that information again:

```elixir
@doc """
Expand All @@ -645,7 +636,7 @@ def load(filename) do
end
```

9. Pipe Operator. What if we wanted to call some of our functions in succession
#### Pipe Operator. What if we wanted to call some of our functions in succession
to another. Let's create a function that creates a zoo, randomises it and then
returns a selected number of animals to go and see:

Expand Down

0 comments on commit c7cda42

Please sign in to comment.