Laws actually resemble immutable data structures pretty strongly! When a law is repealed, it's not simply erased, but rather a new law is passed that says "this law repeals that old law." When a law is changed, it's not rewritten, but a new law is passed that says "Section X of law Y is changed to read, 'blah blah blah.'" The full law in effect at any given time is just the sum of all those changes.
End digression!