28. def categories(num)
categories = []
while categories.length < num do
category = fetch('commerce.department')
categories << category unless categories.
include?(category)
end
categories
end
Ruby example
69. def categories(num)
categories = []
while categories.length < num do
category = fetch('commerce.department')
categories << category unless categories.
include?(category)
end
categories
end
Ruby example
74. def categories(n), do: categories(n, [])
def categories(0, result), do: result
def categories(n, result) do
new = fetch_category
case (new in result) do
true -> categories(n, result)
false -> categories(n - 1, [new | result])
end
end
97. def add_report(org, new_employee)
Takes the top of an organization, and a
new employee
and returns either the org with the
employee added… or the org
unchanged
115. Where to find small problems
• adventofcode.com
• exercism.io
• “Exercises for Programmers”, by Brian
Hogan
• The Little Schemer, Friedman and Felleisen
116. #2: Read the Elixir source, and the
source of the better known Elixir libs
117. #3: Do it again and again. Mix small
problems in with your big projects
118. #5: Stay in touch!
I am “cameronp” on:
• twitter
• medium
• github
• gmail
• elixir slack