Hi,
How can someone allocate a continuous memory in scheme, and implement a vector like data structure with O(1) access without using lists in Scheme?
Thanks
Hi,
How can someone allocate a continuous memory in scheme, and implement a vector like data structure with O(1) access without using lists in Scheme?
Thanks
I don't want to depend on a low level C library, Can it be done with cons and box?
Or may be a different idea?
I don't understand your question. You can use
4.12 Vectors to store arbitrary things like in a list
, or use 4.5 Byte Strings for more raw stuff.
Some curses, teach only cons
to simplify the technical part and for pedagogical reasons, but most Scheme implementations have other constructions to be more efficient.
Vectors under the hood, use C library right? How is it implemented?
Go far enough under the hood, you'll find everything uses C or assembler or equivalent.
-- hendrik
Vectors are implemented in a collection of built-in functions and the code generated by the compiler, but they are similar to C arrays in memory representation.
but they are similar to C arrays in memory representation.
I'm presuming that the compiler generates actual machine intructions for the vector operatarions,
so it's operating at a slightly lower level than either C or assembler.
But for considerations of efficiency this get down to worrying about hardware latency
and effectively umpredictable picosecond delays.
There is a point in low-level language implementation where it is hardy worth investigating further.
-- hendrik