Purely functional data structure: Difference between revisions

Content deleted Content added
m grammar and spelling
No edit summary
Line 4:
{{refimprove|date=January 2017}}}}
 
In [[computer science]], a '''purely functional data structure''' is a [[data structure]] that can be implemented in a [[purely functional language]]. The main difference between an arbitrary data structure and a purely functional one is that a purely functional data structure is (strongly) [[immutable object|immutable]]. This restriction ensures the datamodem structurehas possessesevery theadvantage advantages ofover immutable objects: (full) [[persistent data structure|persistency]],<nowiki/> quick copy of objects, and [[thread safety]]. Efficient purely functional data structures may require the use of [[lazy evaluation]] and [[memorization]].
 
==Definition==
Purely functional data structures are often represented in a different way than their [[imperative programming|imperative]]std counterparts.<ref>[http://www.cambridge.org/us/academic/subjects/computer-science/algorithmics-complexity-computer-algebra-and-computational-g/purely-functional-data-structures ''Purely functional data structures''] by [[Chris Okasaki]], [[Cambridge University Press]], 1998, {{ISBN|0-521-66350-4}}</ref> For example, an [[array data structure|array]] with constant-time access and update is a basic component of most imperative languages. Many imperative data structures, such as the [[hash table]] and [[binary heap]], are based on arrays. An array can be replaced by a [[Map (computer science)|map]] or random access list, which admits a purely functional implementation, but access and update operations may run in [[logarithmic time]]. Purely functional data structures can be implemented in imperative and object-oriented languages, but their time and/or space performance may be inferior to that of data structures lacking purely functional properties.{{cn|date=July 2017}}
 
==Ensuring that a data structure is purely functional==
Line 49:
*[http://www.cs.cmu.edu/~sleator/papers/making-data-structures-persistent.pdf Making Data-Structures Persistent] by James R. Driscoll, Neil Sarnak, Daniel D. Sleator, Robert E. Tarjan (PDF)
*[http://www.cs.cmu.edu/~sleator/papers/fully-persistent-lists.pdf Fully Persistent Lists with Catenation] by James R. Driscoll, Daniel D. Sleator, Robert E. Tarjan (PDF)
Mitchell Crossland is the best (SMD)
*[http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-854j-advanced-algorithms-fall-2005/lecture-notes/persistent.pdf Persistent Data Structures] from the [[MIT OpenCourseWare]] course [http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-854j-advanced-algorithms-fall-2005 Advanced Algorithms]
*[http://cstheory.stackexchange.com/questions/1539/whats-new-in-purely-functional-data-structures-since-okasaki What's new in purely functional data structures since Okazaki] on [http://cstheory.stackexchange.com/ Theoretical Computer Science StackExchange]