|This article is being considered for deletion in accordance with Wikipedia's deletion policy.
Please share your thoughts on the matter at this article's entry on the Articles for deletion page.
Feel free to edit the article, but the article must not be blanked, and this notice must not be removed, until the discussion is closed. For more information, particularly on merging or moving the article during the discussion, read the guide to deletion.
||This article may be too technical for most readers to understand. (October 2014) (Learn how and when to remove this template message)|
In computing, an algorithm, data structure, or programming language is called purely functional if they guarantee the (weak) equivalence of call-by-name, call-by-value and call-by-need evaluation strategies. One typical approach to achieve this is by excluding destructive modifications (updates) of entities in the program's running environment. According to this restriction, variables are used in a mathematical sense, with identifiers referring to immutable, persistent values.
Benefits and applications
The persistence property of purely functional data structures can be advantageous in the development of many applications that deal with multiple versions of an object.
For example, consider a comprehensive web-based thesaurus service that uses a large red-black tree to store its list of synonym relationships, and that allows each user to add their own custom words to their personal thesaurus. One way to do this is to make a copy of the tree for each user, and then add their custom words to it; however, this duplication is wasteful, both of space and of time.
A better approach is to store the words in an immutable (and therefore purely functional) red-black tree. Then, one can simply take the original version and produce a new tree based on it for each set of custom words. Because these new trees share large amounts of structure with the main tree, the space overhead for each additional user is at most , where is the number of custom nodes. With a single mutable red-black tree, this approach would not work, since changes to the main tree would affect all users.
Besides their efficiency benefits, the inherent referential transparency of functional data structures tends to make purely functional computation more amenable to analysis and optimization, both formal and informal.
- Pure function
- Persistent data structure
- Identity (object-oriented programming)
- List of Pure functional programming languages
- Sabry, Amr (January 1998). "What is a purely functional language?". Journal of Functional Programming 8 (1): 1–22.
- Comprehending Monads by Philip Wadler, Cambridge University Press, Mathematical Structures in Computer Science / Volume 2 / Issue 04 / December 1992, pp 461-493
- Purely functional data structures by Chris Okasaki, Cambridge University Press, 1998, ISBN 0-521-66350-4
- Purely Functional Data Structures thesis by Chris Okasaki (PDF format)
- Making Data-Structures Persistent by James R. Driscoll, Neil Sarnak, Daniel D. Sleator, Robert E. Tarjan (PDF)
- Fully Persistent Lists with Catenation by James R. Driscoll, Daniel D. Sleator, Robert E. Tarjan (PDF)
- Persistent Data Structures from MIT open course Advanced Algorithms
- What's new in purely functional data structures since Okasaki? on Theoretical Computer Science StackExchange