This file contains hidden or 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 hidden or 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 hidden or 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
| dummy |
This file contains hidden or 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 hidden or 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
| import System.Environment (getArgs) | |
| main :: IO () | |
| main = do | |
| args <- getArgs | |
| let n = read $ head args :: Int | |
| putStrLn . show $ fib n | |
| fib :: Int -> Integer | |
| fib 0 = 0 |
This file contains hidden or 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
| Git clone https://github.com/parroty/exfirebase | |
| cd exfirebase | |
| mix deps.get | |
| iex -S mix |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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]) |
NewerOlder