The Algebra of Data, and the Calculus of Mutation
blog.lab49.com
blog.lab49.com
peek : int * int^3 -> int
pos : int * int^3 -> 3*int^2
poke : int * 3*int^2 -> int^3
The functions would behave like this: peek 2 (98,76,54) = 76
pos 2 (98,76,54) = (98,_,54)
poke 77 (98,_,54) = (98,77,54)
You could chain them like this: poke 99 (pos 1 (98,76,54)) = (99,76,54)
poke 77 (pos 2 (98,76,54)) = (98,77,54)
poke 55 (pos 3 (98,76,54)) = (98,76,55)