Content deleted Content added
→Definition: I repeat the citation of Okasaki's introduction if it please you. But everything is already there. I also rephrase the paragraph |
|||
Line 6:
==Definition==
Formally a ''Purely functional data structure'' is a data structure which can be implemented in a [[purely functional language]], such as [[Haskell]]. In practice, it means that the data structures must be built using only persistent data structures such as tuples, [[sum type]]s, [[product type]]s, and basic types such as integers, characters, strings. Such a data structure is necessarily persistent. However, all persistent data structures are not purely functional {{r|Okasaki-book|16}}. For exemples a [[persistent array]] is a data-structure which is persistent and which is implemented using an array, thus which is not purely functional.
In the book ''Purely functional data structures, Okasaki compare destructive updates to master chef's knives{{r|Okasaki-book|2}}. Destructive updates can not be undone, and thus they should not be used unless it is certain that the previous value is not required anymore. However, destructive updates can also allow efficiency that can not be obtained using other techniques. For example, a data structure using an array and destructive updates may be replaced by a similar data structure where the array is replaced by a [[Map (computer science)|map]], a random access list, or a tree, which admits a purely functional implementation. But the access cost may increase from constant time to to [[logarithmic time]].
==Ensuring that a data structure is purely functional==
|