A Different Approach
Explore how representing data with lists of lists or maps affects ease of access and updates in Elixir projects. Understand why structuring data with your access patterns in mind leads to cleaner, more maintainable code in functional programming.
We'll cover the following...
We'll cover the following...
Making the board using a list of strings
What if we make one small change by representing the board as a list of lists of strings? Here are the commands for accessing and inserting elements:
Executable
Output
iex(1)> board = [ ["O", " ", " "],
...(1)> [" ", "X", " "],
...(1)> [" ", " ", " "] ]
[["O", " ", " "], [" ", "X", " "], [" ", " ", " "]]
iex(2)> ...