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 Person do | |
defstruct [:name, :age] | |
def with do | |
{Person.Builder, %{}} | |
end | |
defmodule Builder do | |
def unquote(:'$handle_undefined_function')(:and_with, [{__MODULE__, _acc} = tuple]) do | |
tuple |
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 Permutations do | |
def permutate([]), do: [[]] | |
def permutate(list) do | |
for n <- list, | |
p <- permutate(list -- [n]), | |
do: [n | p] | |
end | |
end |