Purely functional data structure: Difference between revisions

Content deleted Content added
removing spaces
m similar to similarly
Line 26:
 
===Laziness and memoization===
Lazy evaluation is particularly interesting in a purely functional language because the order of the evaluation never changes the result of a function. Therefore, lazy evaluation naturally becomes an important part of the construction of purely functional data structures. It allows computations to be done only when its result is actually required. Therefore, the code of a purely functional data structure can, without loss of efficiency, consider similarsimilarly data that will effectively be used and data that will be ignored. The only computation required is for the first kind of data that will actually be performed.
 
One of the key tools in building efficient, purely functional data structures is memoization. When a computation is done, it is saved and does not have to be performed a second time. This is particularly important in lazy implementations; additional evaluations may require the same result, but it is impossible to know which evaluation will require it first.