purely-functional

What is the benefit of purely functional data structure?

淺唱寂寞╮ 提交于 2019-11-27 09:32:05
问题 There are large number of texts on data structures, and libraries of data structures code. I understand that purely functional data structure is easier to reason about. However I have trouble to understand the real world advantage of using purely functional data structure in pragmatic code (using functional programming language or not) over the imperative counterpart. Can somebody provide some real world cases where purely functional data structure has advantage and why? Examples along the

Explicit Purely-Functional Data-Structure For Difference Lists

冷暖自知 提交于 2019-11-27 07:01:29
问题 In Haskell, difference lists, in the sense of [a] representation of a list with an efficient concatenation operation seem to be implemented in terms of function composition. Functions and (dynamic) function compositions, though, must also be represented somehow in the computer's memory using data structures, which raises the question of how dlists could be implemented in Haskell without using function compositions, but, rather, through some basic purely-functional node-based data structures.

Purity vs Referential transparency

半世苍凉 提交于 2019-11-27 00:25:39
问题 The terms do appear to be defined differently, but I've always thought of one implying the other; I can't think of any case when an expression is referentially transparent but not pure, or vice-versa. Wikipedia maintains separate articles for these concepts and says: From Referential transparency: If all functions involved in the expression are pure functions, then the expression is referentially transparent. Also, some impure functions can be included in the expression if their values are