Skip to content

Instantly share code, notes, and snippets.

Erlang/Elixir syntax reference

This reference is aimed at allowing you to comfortably read erlang documentation and consume terms printed in Erlang format. It does not aim at allowing you to write Erlang code.

This is a modified version of http://elixir-lang.org/crash-course.html

Data types

Erlang and Elixir have the same data types for the most part, but there are a number of differences.

Operating System: macOS
CPU Information: Apple M1 Max
Number of Available Cores: 10
Available memory: 32 GB
Elixir 1.14.1
Erlang 25.1.1
Benchmark suite executing with the following configuration:
warmup: 2 s
time: 15 s
@michalmuskala
michalmuskala / decode.txt
Last active June 3, 2022 09:32
Jason benches
Operating System: macOS"
CPU Information: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Number of Available Cores: 8
Available memory: 16 GB
Elixir 1.7.0-dev
Erlang 21.0
Benchmark suite executing with the following configuration:
warmup: 5 s
time: 30 s
#!/usr/bin/env elixir
defmodule Committer do
defstruct [:name, :email]
def list(repo) do
repo
|> from_repo
|> Stream.unfold(fn str ->
case String.split(str, "\n", parts: 2, trim: true) do
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Language.Brainfuck.Parser
(parse)
where
import Control.Monad.Except
import Control.Monad.State
data ParseError = Unexpected Char

Keybase proof

I hereby claim:

  • I am michalmuskala on github.
  • I am michalmuskala (https://keybase.io/michalmuskala) on keybase.
  • I have a public key ASD4xBbD3s6nedsVDfSRtGTLOa33wAWB18kagmvYs7ktago

To claim this, I am signing this object:

defmodule FizzBuzz do
def fizzbuzz(a) when rem(a, 3) == 0 and rem(a, 5) == 0, do: "FizzBuzz"
def fizzbuzz(a) when rem(a, 3) == 0, do: "Fizz"
def fizzbuzz(a) when rem(a, 5) == 0, do: "Buzz"
def fizzbuzz(a), do: a
end
1..100 |> Enum.map(&FizzBuzz.fizzbuzz/1) |> Enum.each(&IO.puts/1)