Purely functional data structures and algorithms