3 ms·
Interesting. Maybe naively, I always assumed that the difference between those two data structures is that an array has integer indices to be mapped trivially t
by pmontra 11y ago
Interesting. Maybe naively, I always assumed that the difference between those two data structures is that an array has integer indices to be mapped trivially to RAM and CPU index registers, and associative arrays are hash tables. I googled this https://en.wikibooks.org/wiki/Ada_Programming/Types/array https://en.wikibooks.org/wiki/Ada_Programming/Types/array and it seems that arrays in Ada can have only discrete indices. Example from there
type Character_Counter is array (Character) of Natural;
I guess that the compiler maps Character to integers and uses index registers to access RAM. That would be character.ord in Ruby and in many other languages but it's a lower level construct.
- Avshalom 11y agoI can for instance do type throw is (ROCK, PAPER, SCISSORS); type result is (ME, YOU, DRAW); winner : array (throw, throw) of result := ( (DRAW, YOU, ME), (YOU, DRAW, ME), (ME, YOU, DRAW)); YOU = winner(ROCK, PAPER); --would evaluate to true because types are cool.