haskell - What's the best technique to generate a random-access data structure lazily? -


in haskell, i'd generate list of random integers of undetermined length. (however, less 1 million.)

i'm not need elements of list immediately, i'd generate lazily. however, once generated, i'll need access elements in list random access. so, assume best technique copy infinite list array. however, don't know if arrays can "interchanged" lists -- instance, once want generate more items of list, want start left off expand array.

anyways, perhaps should settle log(n) tree structure instead of array? think?

does haskell have tree structure sequential elements can accessed using list-like api?

if have prng, values generated seeds close should independent, can choose initial seed, each cell i in array prng(seed+i).

this using hash function :p

if way, don't need array, can have function getrandomvalue seed = prng (seed+i). whether or not better array of lazy values depend on complexity of prng, either way you'll o(1) access.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -