Back in college I struggled with Calculus; had a hard time grasping the concept of the day. After a semester break, I’d ace the test reviewing previous topics. Just took awhile for the concepts to settle into my brain.
I’m experiencing a similar effect with Elixir. Came back after a few days and was able to make significant progress on Chapter 13’s Formatting a Table exercise.
Things are starting to click.
There’s always a function for it.
- Use
[element | _]
, notlist[0]
. - Use
Map.fetch(map, key)
, notmap["key"]
. - Use
elem(tuple, 0)
, nottuple[0]
- Use
Every block is a local scope.
# Doesn't work row = [] for header <- headers do row = [function(data) | row] end # row is still [] # Works row = for header <- headers do function(data) end
Enum.map and Enum.zip are your friends.
dbg
andNext
, though limited, are invaluable.Breakpoints are set by arity.
Tests are easier to write on small functions. In Python I’d end up building more complex functions as it felt reasonable to do ‘one more thing’ in a function. Smaller functions feel natural in Elixir.
All notes and comments are my own opinion. Follow me at @rgacote@genserver.social