A sequence of pairs of integers shall be stored in a way that it can be efficiently iterated over. AFAIK, the best is to have one number after the other in a contiguous chunk of memory. If I were to use an array and represent each pair (a,b) as a (cons a b), then I presume that not the integers will be stored in the array, by pointers to those cons cells. This is not cache-efficient. Can we somehow tell the array: store the object, not a reference to it?
Of course, I can have an array of integers a,b,... and put an abstraction in between that will give me two consecutive numbers as a pair. But I'm trying to find a native way first.
Of course, I can have an array of integers a,b,... and put an abstraction in between that will give me two consecutive numbers as a pair. But I'm trying to find a native way first.