user1767754
user1767754

Reputation: 25134

How to get Infinite Data-Structures?

There are some algorithms which need "infinite Data-Structures" like an infinite two-dimensional grid of cells. How is such a problem tackeld? Are they maybe using "pseudo-infinite" structures where just a large amount of data is used? Or is there somehow a "resize" implemented, when capacity is not enough?

I am using a Cellular-Automata Algorithm, which is beeing computed on a 2000 x 2000 grid, but i would like to have the grid infinitely.

Upvotes: 1

Views: 654

Answers (1)

Robert Harvey
Robert Harvey

Reputation: 180868

By using lazy evaluation.

Delaying the calculation (or creation) of each item in an infinite data structure until it is needed eliminates the problem of having to create an infinite data set.

Upvotes: 3

Related Questions