In Haskell, I would like to generate a list of random integers of indefinite length. (However, less than 1 million.)
Iโm unlikely to need all the elements of the list at once, so I would like to generate it lazily. However, after the generation, I will need to access the items in the random access list. So, I believe that the best method would be to copy an infinite list to an array. However, I donโt know if arrays can be "swapped" with lists very easily - for example, as soon as I want to generate more list elements, I want to start where I left off but expand the array.
In any case, maybe I should solve for some tree structure log (n) instead of an array? What do you think?
Does Haskell have a tree structure for sequential items that can be accessed using a list-like API?
source share