Useful Elixir Links

The language:

The forum

The school

Style Guide:

The package mangement:


Salvaged from Stackoverflow:

The mentored exercism:

Profiling Elixir:

RNA Transcription

Elixir has a very clean syntax for codepoints that would help here:

```?G``` is the codepoint of ```G```

Single quoted strings are simply lists of codepoints.
If you use the codepoint syntax on both sides of your translation function then you can reduce this problem to an call.

Unless you can handle an error "let it crash".

```Don’t code defensively - Joe Armstrong```

Elixir applications are usually constructed with supervisors (this is beyond the scope of these exercises):

It's good practice in Elixir to make all helper functions private (defp). This helps the compiler to warn that they are not used (which is useful in itself) but also allows easy detection of typos.

Having a smaller surface area for a module also allows easier refactoring.

Word Count

String.split has a ```trim: true option``` that will allow you to combine the split and replace into one operation. . (look at trim: true)

String.split(~r/[^[:alnum:]\-]/u, trim: true)

Here is a more general regex that may be of use:

Also, consider extracting the regex as a descriptively named module attribute.

There are two solutions to this problem:
* Recursive
* Decimal

Have a look at other students solutions.
Good luck with the next exercise.

Using hardcoded test data is kind of cheating.

This is a simple problem and can be solved without using regex. There is nothing wrong with regex (Elixir's regex support is very powerful) it's just not needed here.

Can you solve this in 5 cond clauses with no nesting?
Extracting defp helper functions will avoid duplication and allow you to clearly state intent.

These may be of use:


String.upcase(input) != String.downcase(input) if there is a letter present.

Here is a style guide that may be of use:

Elixir uses xxx? for query functions (as you have used), but the ```is_``` prefix is usually reserved for guard clauses (something that you will need for later exercises).
Bank Account

Good solution.
There are four solutions to this problem:
* GenServer
* Agents
* send/receive
* ets

There is one choice: do you close the process with the account?

You have chosen the simplest of the four.
Have a look at the other student's solutions.

Good luck with the next exercise.
Beer song:

Elixir supports multiple function clauses distinguished by pattern matching, this is clearer than using a guard clause (the first to match is used, so order is important):

def verse(2), do: ...
def verse(1), do: ...
def verse(0), do: ...
def verse(number), do: ...

Elixir has multi-line strings delimited by ```"""```

You can combine the two lyrics with a default (param \\ default_value).

Enum.map_join is cleaner than the component parts.

Ranges are enumerable.

Robot Simulator

Consider using defguard to make the validation more explicit.

direction/1 and position/1 are clearer using pattern matching:

def direction(%{direction: dir}), do: dir

Consider using the map update syntax:

%{robot | position: new_position }

You are using a lot of magic numbers, 10 in particular has multiple meanings. Consider extracting some module attributes.
Elixir Exercises Yet To Mentor:

 "Atbash Cypher"
 "Grade School"
 "OCR Numbers"
 "Palindrome Products"
 "Rail Fence Cypher"
 "Spiral Matrix"