This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule QuickSort do | |
def sort([]), do: [] | |
def sort([head|tail]) do | |
{lesser, greater} = Enum.partition(tail, &(&1 < head)) | |
sort(lesser) ++ [head] ++ sort(greater) | |
end | |
end | |
IO.inspect QuickSort.sort([1,6,3,4,2,5]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule XmlParser do | |
require Record | |
Record.defrecord :xmlElement, Record.extract(:xmlElement, from_lib: "xmerl/include/xmerl.hrl") | |
Record.defrecord :xmlText, Record.extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl") | |
@xml """ | |
<result> | |
<event> | |
<title>My event</title> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
erlang 18.0 | |
elixir 1.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Fetcher do | |
def db_value_for(key) do | |
IO.puts "processing..." | |
"db value for #{key}" | |
end | |
defmacro get(map, key, default \\ nil) do | |
quote do | |
case Map.get(unquote(map), unquote(key)) do | |
nil -> unquote(default) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies: | |
pre: | |
- bash ./install-otp_src_17.0.sh | |
- bash ./install-elixir.sh | |
cache_directories: | |
- otp_src_17.0 | |
- elixir | |
test: | |
pre: | |
- ln -s ~/circle_sample/otp_src_17.0/bin/erl ~/bin/erl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ExFuture.HelperTest do | |
use ExUnit.Case | |
use ExFuture | |
test "future block" do | |
f = future do | |
3 * 3 | |
end | |
assert 9 == value(f) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule SampleFuture do | |
require Future | |
def fib(0), do: 0 | |
def fib(1), do: 1 | |
def fib(n), do: fib(n - 1) + fib(n - 2) | |
defmacro benchmark([do: content]) do | |
quote do | |
s = :erlang.now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ExVCR.MockTest do | |
use ExUnit.Case | |
import ExVCR.Mock | |
setup_all do | |
ExVCR.Config.cassette_library_dir("fixture/vcr_cassettes", | |
"fixture/custom_cassettes") | |
:ok | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ApplicationRouter do | |
use Dynamo.Router | |
filter Dynamo.Filters.MethodOverride | |
prepare do | |
conn = conn.fetch([:cookies, :params]) | |
conn.assign :layout, "main" | |
end | |
@doc "index" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ApplicationRouter do | |
use Dynamo.Router | |
filter DynamoScaffold.Filters.MethodOverride | |
prepare do | |
conn = conn.fetch([:cookies, :params]) | |
conn.assign :layout, "main" | |
end | |
@doc "index" |
NewerOlder