What is the benefit of purely functional data structure?

前端 未结 5 1004
南方客
南方客 2020-12-12 14:27

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. Howe

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 14:53

    Take this little snippet of F#:

    let numbers = [1; 2; 3; 4; 5]
    

    You can say with 100% certainty that that is a immutable list of integers 1 through 5. You can pass around a reference to that list and never have to worry that the list may have been modified. That is enough reason for me to use it.

提交回复
热议问题