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 MyRecursion do | |
def sum(list, fun) do | |
do_sum(list, fun, 0) | |
end | |
defp do_sum([], _fun, acc) do | |
IO.puts acc | |
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 M do | |
defmacro __using__(_args) do | |
quote do | |
@count 0 | |
import unquote(__MODULE__), only: :macros | |
end | |
end | |
defmacro p do | |
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 Example do | |
def parse(elements, acc \\ []) | |
def parse([], acc), do: Enum.reverse(acc) | |
def parse([{"table", attrs, nested} | rest], acc) do | |
parse(rest, [{"v-table", attrs, parse_table(nested)} | acc]) | |
end | |
def parse([{"thead", _attrs, nested} | rest], acc) 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 Example do | |
def parse(elements, acc \\ []) | |
def parse([], acc), do: Enum.reverse(acc) | |
def parse([{"table", attrs, nested} | rest], acc) do | |
parse(rest, [{"v-table", attrs, parse_table(nested)} | acc]) | |
end | |
def parse([{"thead", _attrs, nested} | rest], acc) 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 Example do | |
def parse(elements, acc \\ []) | |
def parse([], acc), do: Enum.reverse(acc) | |
def parse([{"table", attrs, nested} | rest], acc) do | |
parse(rest, [{"v-table", attrs, parse(nested)} | acc]) | |
end | |
def parse([{"thead", _attrs, nested} | rest], acc) 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 Example do | |
def parse(elements, acc \\ []) | |
def parse([], acc), do: Enum.reverse(acc) | |
def parse([{"table", attrs, nested} | rest], acc) do | |
parse(rest, [{"v-table", attrs, parse(nested)} | acc]) | |
end | |
def parse([{"thead", _attrs, nested} | rest], acc) 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 Example do | |
def parse(elements, acc \\ []) | |
def parse([], acc), do: Enum.reverse(acc) | |
def parse([{"table", attrs, nested} | rest], acc) do | |
parse(rest, [{"v-table", attrs, parse(nested)} | acc]) | |
end | |
def parse([{"thead", _attrs, nested} | rest], acc) 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 Example do | |
def parse([]), do: [] | |
def parse([{"table", attrs, nested} | rest]) do | |
[{"v-table", attrs, parse(nested)} | parse(rest)] | |
end | |
def parse([{"thead", _attrs, nested} | rest]) 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
basic_query = %{ | |
"version" => true, | |
"fields" => [ | |
"title", | |
"type", | |
"tags", | |
"searchable", | |
"searchable_from", | |
"searchable_until", | |
"created_at", |
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
{a, b, c} = {:hello, "world", 42} | |
IO.inspect {a, b, c} |
NewerOlder