Skip to content

Instantly share code, notes, and snippets.

View efexen's full-sized avatar

Ville Hellman efexen

View GitHub Profile
@andypike
andypike / fizzbuzz.exs
Created January 4, 2016 10:30
FizzBuzz in Elixir
defmodule FizzBuzz do
def convert_num(0, 0, _), do: "FizzBuzz"
def convert_num(0, _, _), do: "Fizz"
def convert_num(_, 0, _), do: "Buzz"
def convert_num(_, _, n), do: n
def fizz_buzz(n) do
convert_num rem(n, 3), rem(n, 5), n
end
@andypike
andypike / classes.rb
Last active December 15, 2015 22:09
My first experiment with a simple IoC container in Ruby. To run this sample do this: $ ruby ioc.rb
# defining various components of the system
# notice the classes know nothing about the container
# as they require the dependencies to operate, they should be passed into the constructor
class Nails
def to_s
"nails"
end
end
class Glue