Arrays implementation in erlang

前端 未结 2 1233
挽巷
挽巷 2021-01-19 07:51

My question is, how are arrays implemented in Erlang, as opposed to lists.

With immutable types doing things like,

move ([X | Xs], Ys) ->
    [X          


        
2条回答
  •  借酒劲吻你
    2021-01-19 08:10

    You can find the source code here. It looks like, as @rvirding mentioned, that an array is a functional tree. I haven't studied the implementation deeply--and there's no reference in the source to the data-structure's origin--but a quick skim suggests a lookup worst-case is some logarithmic factor of N.

    I'd love a correction if someone else is more familiar with this source / has a moment to study it.

提交回复
热议问题