I hereby claim:
- I am sasa1977 on github.
- I am sasajuric (https://keybase.io/sasajuric) on keybase.
- I have a public key whose fingerprint is F1D6 33EA A754 1F56 947B 1083 FD82 5822 1AE5 C7F8
To claim this, I am signing this object:
| defmodule Fibonacci do | |
| defrecordp :fib_state, Fibonacci, current: 0, previous1: nil, previous2: nil | |
| def new do | |
| fib_state() | |
| end | |
| def value(fib_state(current: current)) do | |
| current | |
| end |
| defmodule NumbersInput do | |
| def start do | |
| IO.stream(:stdio, :line) | |
| |> Stream.flat_map(&tokenize/1) | |
| |> Stream.take_while(&(&1 > -1)) | |
| end | |
| defp tokenize(line) do | |
| line | |
| |> String.split(" ") |
| defmodule HttpRequester do | |
| use GenServer.Behaviour | |
| def start_link(_) do | |
| :gen_server.start_link(__MODULE__, nil, []) | |
| end | |
| def fetch(server, url) do | |
| :gen_server.cast(server, {:fetch, url}) | |
| end |
| -module(an_actor). | |
| -behaviour(gen_server). | |
| -export([ | |
| start_link/0, sum/3, | |
| init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3 | |
| ]). | |
| start_link() -> gen_server:start_link(?MODULE, [], []). |
| defmodule User do | |
| fields = [:name, :age] | |
| defrecordp :user, fields | |
| def new, do: user() | |
| fields | |
| |> Enum.each(fn(field) -> | |
| def unquote(field)(record) do |
I hereby claim:
To claim this, I am signing this object:
| defmodule Test do | |
| @proto_version "1.0" | |
| def process_options(opts) do | |
| ["-proto", @proto_version] ++ log_opt ++ process_input_options(opts) | |
| end | |
| defp log_opt do | |
| case :application.get_env(:porcelain, :goon_driver_log) do | |
| :undefined -> [] |
| # Works on Elixir 1.0.x | |
| # Usage: just paste to `iex` shell, or run `elixir conway.ex` | |
| defmodule Sum do | |
| defstruct value: 0 | |
| def value(%Sum{value: value}), do: value | |
| def add(%Sum{value: value} = sum, x) do | |
| %Sum{sum | value: value + x} |
| # Works on Elixir 1.0.x | |
| # Usage: just pust to `iex` shell, or run `elixir conway.ex` | |
| defmodule Sum do | |
| defstruct value: 0 | |
| def value(%Sum{value: value}), do: value | |
| def add(%Sum{value: value} = sum, x) do | |
| %Sum{sum | value: value + x} |
| defmodule Prime do | |
| def prime_factors(number) do | |
| first_divisor = | |
| div(number, 2)..1 | |
| |> Enum.find(&(rem(number, &1) == 0)) | |
| case first_divisor do | |
| 1 -> [number] | |
| _ -> prime_factors(div(number, first_divisor)) ++ prime_factors(first_divisor) | |
| end |