[erlang-questions] How to Update List Elements A Lot

Erik Søe Sørensen eriksoe@REDACTED
Tue Jul 21 19:16:51 CEST 2015


Are the updates so scattered? If they are a series of front-to-back or
back-to-front updates, then there's not much of a problem. Certain other
fixed patterns (eg, swapping each pair of values, or in general replacing
..., X, Y,... with ..., f(X, Y), g(X, Y),... ) are easy too, with lists or
binaries. The really hard case is when the sequence of indexes of the
updates is not fixed. Purely functional data structures don't do such
patterns too well, performance-wise - although, as has been pointed out by
others, it may perform well enough for the purpose.
The "ramfile" driver may be a solution,  although last time I checked it
wasn't too fast.
/Erik
Den 21/07/2015 09.56 skrev "Jesper Louis Andersen" <
jesper.louis.andersen@REDACTED>:

>
> On Tue, Jul 21, 2015 at 6:00 AM, Hugo Wang <w@REDACTED> wrote:
>
>> In other language, like C or Python, we can init an output list and then
>> update its elements inline. In Erlang, what I currently do, would make a
>> copy of the list every time when an element need to update. This looks not
>> quite right.
>>
>
> Do you have a small snippet of an inner loop somewhere? It may be easier
> to recommend an approach then. Do note that crypto-stuff in Erlang is
> perhaps not the best approach since the complexity of the VM makes it
> harder to account for side channels.
>
>
> --
> J.
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150721/62f1e5d2/attachment.htm>


More information about the erlang-questions mailing list