haakonst / elixir-fp-intro

Introduction to functional programming with Elixir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction to functional programming with Elixir

The goal with the workshop is to get a brief introduction to functional programming using Elixir as programming language. We'll go through some of the basic language features in Elixir and concepts in functional programming by looking at some examples. Then we'll work on some exercises. The idea is to implement a basic calculator, adding numbers listed in a string, starting with something very very basic and then make stepwise refinements to the implementation. The exercises are shaped as a kata for test driven development. The test cases have already been defined. Each exercise/implementation step have a test case which must succeed for the exercise to be complete:

To avoid noise from test cases for steps that fail because you didn't reach those steps yet, update the function StringCalculator.step/0 to return the number of the exercise/step you're at.

Slides for this workshop.

For this workshop you need to have Elixir on your computer. You can get it by either installing it directly on your computer or you can use the official Docker image for Elixir.

Getting started

Clone this Git repository

> cd C:/src/
> git clone https://github.com/haakonst/elixir-fp-intro.git
> cd C:/src/elixir-fp-intro/

Install Elixir or run the Docker image

Do either of the following:

  • Install Elixir and Erlang by following the installation instructions
  • Ensure Docker is installed and that your C: drive is shared and run either of these commands (the latter is just a script file containing the former):
    • docker run --rm -it -v "C:/src/elixir-fp-intro:/elixir-fp-intro" -w /elixir-fp-intro elixir /bin/bash
    • .\docker-run.ps1

Run the test cases

mix test

Resources

Commonly used modules

Less commonly used modules

About

Introduction to functional programming with Elixir


Languages

Language:Elixir 98.2%Language:PowerShell 1.8%