Run the file with:
$ iex digipet.ex
The create a pet via:
iex> pet = DigiPet.new "Franklin"
defmodule Scheduler do | |
require Integer | |
@doc """ | |
Generate a number of teams (3 or more) | |
""" | |
def generate_teams(number) when number < 3, do: IO.puts "Need to specify at least 3 teams" | |
def generate_teams(number) do | |
team_names |
defmodule Caesar do | |
@doc """ | |
Encode a file with a Caesar Cipher. | |
Shift value must be between 0 and 25. Works best with only aplha characters. Spaces will be left as spaces. | |
Usage: | |
$ iex caesar.ex | |
iex> Caesar.encode_file("/path/to/file", 13) |
defmodule Identicon do | |
def make(username) do | |
username | |
|> encode | |
|> draw | |
end | |
defp encode(username) do | |
:crypto.md5(username) |
FROM trenpixster/elixir:1.0.1 | |
COPY . /phoenix_app | |
ENV MIX_ENV prod | |
WORKDIR /phoenix_app | |
RUN mix do deps.get, compile | |
EXPOSE 4000 | |
CMD ["mix", "phoenix.start"] |
defmodule Terrain do | |
def generate do | |
size = 65 # or 129, 513, 1025 (2^x + 1) | |
initial_state(size) | |
|> diamond { 0, 0 }, { size-1, size-1 } | |
end | |
defp diamond(current, { x1, y1 }, { x2, y2 }) when x2 == x1 + 2 and y2 == y1 + 2 do | |
current |
defmodule FizzBuzz do | |
@doc """ | |
Given a range, returns an array of values conforming to the FizzBuzz pattern. | |
## Example | |
FizzBuzz.calculate 1..15 | |
-> 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz | |
""" | |
def calculate(range) do |