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 A do | |
defmacro __before_compile__(_env) do | |
funs = Enum.map([:a, :b], fn(name) -> | |
quote do | |
def unquote(name)(), do: unquote(name) | |
end | |
end) | |
quote do | |
unquote_splicing(funs) |
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 Bag do | |
defstruct store: %{} | |
def new do | |
%Bag{} | |
end | |
def put(%Bag{store: store}, thing) do | |
%Bag{store: Map.update(store, thing, 1, &( &1 + 1))} | |
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
@proto_version "1.0" | |
def process_options(opts) do | |
ret = Enum.reduce(opts, [], fn | |
{:in, _}, ret -> ["-in"|ret] | |
{:err, :out}, ret -> ["-err", "out"|ret] | |
{:err, :err}, ret -> ["-err", "err"|ret] | |
{:dir, dir}, ret -> ["-dir", dir|ret] | |
_ -> ret | |
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 Chat.Client do | |
def join(server) do | |
client_send server, :join | |
end | |
def say(server, message) do | |
client_send server, { :say, message } | |
end | |
def leave(server) do |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style type="text/css"> | |
@import url("http://github.com/simplegeo/polymaps/raw/v2.4.0/examples/example.css"); | |
html, body {height: 100%;} | |
svg {display: block;} | |
.layer circle {fill: #f00;stroke: #000;stroke-width: 2px;} | |
</style> |
OlderNewer