Playing With Fire

Exploring the web one Elixir at a time

The Capture Operator

The capture operator works a little bit like capture groups in regular expressions, but for function arguments. Use of this allows for shortcutting and making more readable short anonymous functions.

Read more...

Strings in Elixir

Common features

As is common in programming, Elixir has two string formats: single-quoted and double-quoted. These two representations have many things in common:

  • UTF-8 character encoding
  • they can contain escape sequences
  • they allow string interpolation
  • they have a heredoc representation

Read more...

[ ] or Lists

Of all the data structures that you might use in Elixir, the one that you will undoubtly use the most is the list.

In Elixir a list is a what is commonly referred to in other languages as a linked-list and is used to contain a collection of items of all the same type.

Read more...

Elixir Types

Elixir has many of the types that you would expect from a modern programming language. The following list details these:

  • integers
  • floating-point numbers
  • atoms
  • ranges
  • regular expressions
  • PIDS (process ids)
  • ports
  • tuples
  • lists
  • keyword lists
  • maps
  • binaries
  • structs

Read more...

What is this Elixir anyway?

I thought that I should spend some time looking at the basics of Elixir. I will try very hard not to rehash the material that is already out there, but some crossovers might happen.

Read more...

Elixir Basics

I was recently asked to put something together that covered the basics of Elixir but figured that this was already covered pretty well in other places like the Getting Started guide on the Elixir Language website and I didn’t want to just regurgitate the content of those texts.

Read more...

Using eWebmachine to create a link shortener (part 4)

In the previous posts, we have been using the temporary Erlang Term Storage or ETS to store the data. As this is an in-memory store, any data that is stored is lost whenever the application is stopped.

In this post, we will look to change this and make the data persist between application restarts. To do this we will be using Disc-backed Erlang Term Storage - DETS. This writes the data to a specified file on the disc. For this application using DETS is fine as the data requirements are very small. Should this site take off, then I would recommend using Mnesia.

Read more...