为什么会在函数式编程(erlang)中使用数组而不是列表?(Why one would use array in functional programming (erlang) instead of

编程入门 行业动态 更新时间:2024-10-24 19:29:36
为什么会在函数式编程(erlang)中使用数组而不是列表?(Why one would use array in functional programming (erlang) instead of lists?)

当你打算使用数组模块时 - 以及何时通常在函数式编程中使用数组 - 在这种情况下是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.

更多推荐

本文发布于:2023-08-02 23:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1382487.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:会在   数组   函数   而不是   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!