Access Patterns Shape Data Structures
In functional programming, data structures are inextricably linked to functions. Building good programs means considering how those programs use the data. Some data structures are primarily read-only and others exist to be updated. As you saw in the previous chapter, some datatypes are easier to update than others.
Let’s take a very simple programming problem, representing a tic-tac-toe game. For those rare folks who have never played this game, it’s a childhood favorite where two players, denoted by “X” and “O”, take turns putting their markers on a 3x3 grid. The game ends when the first player gets three in a row.
Since it’s a small game, performance isn’t really a concern. Even when full, our biggest ...
Get Designing Elixir Systems With OTP now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.