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 Combinations do | |
# See http://rosettacode.org/wiki/Combinations#Erlang | |
def comb(0, _), do: [[]]; | |
def comb(_, []), do: []; | |
def comb(n, [h | t]) do | |
lc = for l <- comb(n - 1, t), do: [h | l] |
This file has been truncated, but you can view the full file.
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
2014-01-15 15:57:21,630 [ 0] INFO - #com.intellij.idea.Main - ------------------------------------------------------ IDE STARTED ------------------------------------------------------ | |
2014-01-15 15:57:21,665 [ 35] INFO - #com.intellij.idea.Main - IDE: IntelliJ IDEA (build #IC-133.609, 14 Jan 2014 00:00) | |
2014-01-15 15:57:21,665 [ 35] INFO - #com.intellij.idea.Main - OS: Linux (2.6.32-358.18.1.el6.x86_64, amd64) | |
2014-01-15 15:57:21,665 [ 35] INFO - #com.intellij.idea.Main - JRE: 1.7.0_21-b11 (Oracle Corporation) | |
2014-01-15 15:57:21,665 [ 35] INFO - #com.intellij.idea.Main - JVM: 23.21-b01 (Java HotSpot(TM) 64-Bit Server VM) | |
2014-01-15 15:57:21,671 [ 41] INFO - #com.intellij.idea.Main - JVM Args: -Xms128m -Xmx750m -XX:MaxPermSize=350m -XX:ReservedCodeCacheSize=96m -ea -Dsun.io.useCanonCaches=false -Djava.net.preferIPv4Stack=true -XX:+UseCodeCacheFlushing -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:+HeapDumpOnOutOfM |
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 | |
Enum.each(["a", "b"], fn(name) -> | |
quote do | |
def unquote(name), do: unquote(name) | |
end | |
end) | |
quote 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
defmodule MyMacro do | |
defmacro do_something(query) do | |
quote do | |
args = String.split(unquote(query)) | |
fun = fn(arg) -> IO.inspect var!(unquote(binary_to_atom(arg))) end | |
Enum.each args, fun | |
end | |
end | |
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
% from my unit tests | |
foo = 10 | |
assert 10 == my_macro(:foo) | |
assert 10 == my_macro("foo") | |
% macro |