...

/

Functional Data Structures

Functional Data Structures

Let’s examine some of the core differences between OOP and functional programming.

Writing data structures functionally

Let’s keep exploring our bank account example. Here’s one way to think about it:

account:
%{
     account_number: String, 
     account_holder: %User{},
     balance: Int, 
     transaction_log: [strings],
 }

This structure works fine in many languages, but it is not a functional data structure. There’s a hidden problem. Let’s examine a quick hypothetical ...