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

Richard A. O'Keefe ok@REDACTED
Thu Jul 23 03:26:33 CEST 2015


First, I have to echo Vance Shipley: make it work before you
worry about making it fast.  Second, I get slightly twitchy
when people way "random updates", because they don't always
*mean* "random", just "not sequential".  This confusion goes
deep into IT terminology and is most unfortunate.

I wonder if you are processing the input in blocks of say
64 bytes?  If so, had you considered representing a block
by a spray of separate variables rather than a data structure?
And maybe *computing* the Erlang code to do the shuffling?

There is another issue to consider when translating bit-shuffling
code from other languages to Erlang, and this includes apparently
high level algorithms that appear to be language-neutral.

Erlang gets integer arithmetic *right*.  When you do a left shift,
you do not lose bits off the top.  When you add or subtract, the
result is not taken modulo some weird inhumane number.

There are two consequences.  One is that an algorithm may run
unexpectedly slowly in Erlang because Erlang is computing
intermediate results as specified, not truncating them.  The
other is that explicit masking may be needed to simulate 32-bit
or 64-bit arithmetic, whichever the algorithm assumes.




More information about the erlang-questions mailing list