The confusion is that you are thinking of function in the programming language sense (i.e. A subroutine ) rather than in the mathematical sense (i.e. A function called with the same arguments always returns the same value). The mathematic definition of function necessitates persistent data structures (i.e. You do not modify the dataset but return a new dataset with the modifications).