Skip to content

Instantly share code, notes, and snippets.

@Mousaka
Created November 25, 2016 11:41
Show Gist options
  • Save Mousaka/ce8ae3c6edcd7587da7e2f9f598a4cf8 to your computer and use it in GitHub Desktop.
Save Mousaka/ce8ae3c6edcd7587da7e2f9f598a4cf8 to your computer and use it in GitHub Desktop.
Tried out Elixir a bit with a friend. Was fuuun
defmodule Test do
import List, only: [flatten: 1]
def double(2) do
3
end
def double(5) do
1337
end
def double(n) do
n * 2
end
def printList(list) when list == [] do
IO.puts "SLUT"
end
def printList([h | t]) do
IO.puts h
printList(t)
end
def fac(0), do: 1
def fac(n), do: n * fac(n-1)
@spec hello(String.t) :: Atom.t
def hello(wah \\ "hej"), do: IO.puts wah <> "jsan"
def flata(list) do
flatten list
end
def stuff(a, b) do
b
end
def coolConding(tuple) do
case tuple do
{:ok, n} -> n
{:err, _} -> IO.puts "ERRORRR"
end
end
def facService do
receive do
{sender, x} ->
send sender, { :ok, fac x }
facService
end
end
pid = spawn(Test, :facService, [])
send pid, {self, 9}
def testing do
receive do
{:ok, message} ->
IO.puts message
testing
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment