Functional data structures in JavaScript with Mori
sitr.us
sitr.us
The performance of a transient vector is shockingly close to using a JavaScript array under Google V8 for adding new elements:
http://www.amazon.com/Purely-Functional-Structures-Chris-Oka...
Also check out this link for additional data structures worked on since then or simply not included in the book:
http://cstheory.stackexchange.com/questions/1539/whats-new-i...
JavaScript's `push` mutates data which you'd think you'd want to avoid if you're using a functional library like underscore/lo-dash.
`concat` makes sense to leave out when you consider that arrays already have a `concat` function. But if that's the reasoning, why did underscore/lo-dash include `size` and `max` and all those other things that already exist?
that's why some came up with these abbreviations.
Assembly is worse yet, and mixing C with assembly is basically a path to Lovecraftian madness: I really hate the way intrinsics look. Here's a real snippet from StackOverflow:
a_i = __mm_load_ps(&A[n*i+k]);
b_i = __mm_load_ps(&B[n*k+j]);
c_i = __mm_load_ps(&C[n*i+j]);
__m128d tmp1 = __mm_mul_ps(a_i,b_i);
__m128d tmp2 = __mm_hadd_ps(tmp1,tmp1);
__m128d tmp3 = __mm_add_ps(tmp2,tmp3);
__mm_store_ps(&C[n*i+j], tmp3)
You can also go too far in the other direction: see Java and especially Objective C.Which would mean "functional" is a more general adjective than "persistent" since it includes both persistence and referential transparency.
Wikipedia[1] claims "There also exist persistent data structures which use destructible operations, making them impossible to implement efficiently in purely functional languages"
Recenlty I saw https://github.com/harukizaemon/hamster , similarly immutable, structure sharing, persistent data structures
It's becoming mainstream ...