当你打算使用数组模块时 - 以及何时通常在函数式编程中使用数组 - 在这种情况下是erlang。
谢谢。
when you are going to use array module - and when to use arrays generally in functional programming - erlang in this case.
Thanks.
最满意答案
基本原理是,如果您确实需要使用整数键的功能 (非破坏性)数据结构,那么阵列模块比dict,gb_tree或类似(它可以使用任何类型的值作为键)显着更高效。 索引是从零开始的,因为这对于你想要一个数组的问题通常更有用。
我发现Learn You Some Erlang中的注释非常不合适。
The rationale is that if you do want a functional (nondestructive) data structure using integer keys, then the array module is significantly more efficient than a dict, gb_tree or similar (which can use any kinds of values as keys). And the indexing is zero-based because that's generally more useful for the kind of problems you'd want an array for.
I find the note in Learn You Some Erlang to be quite off the mark.
更多推荐
发布评论