Re: Another quick sequence feature request!
- Posted by Patrick Barnes <mrtrick at gmail.com> Sep 24, 2004
- 471 views
Will, I think that would be a fantastic idea... and while slow in implementation, not much slower than going the other way.. Euphoria stores sequences internally as pointers. The memory location of a 1-d sequence contains a pointer to each element. The memory location of a 2-d sequence contains a pointer to each sub-sequence, each of which contains pointers to elements. To "look at" each element of a sequence, the interpreter needs to make 1 memory look-up for each element. In a 2-d sequence: If we wanted to look at a "horizontal slice", we'd do 1 memory look-up to find the sub-sequence element containing that slice. Then we'd do 1 memory look-up for each element in the slice. Total look-ups: 1 + element_number If we wanted to look at a "vertical slice", there's no single sub-sequence containg that slice, each element of the slice sits in a different sub-sequence. So, to get each element, we need to do 2 look-ups. 1 to find the sub-sequence, 1 to find the element. Total look-ups: 2 * element_number Depending on the size of your 2d sequence, and the rate at which data in the sequence needs to change, you could have 2 copies of the sequence in memory... a vertical and a horizontal copy. Every change has to be made to both sequences. In a few other languages, two indexes can refer to the same data... however it's something that you *REALLY* don't want to make a mistake with. On Thu, 23 Sep 2004 19:42:08 -0500, William Heimbigner <icxcnika at hotpop.com> wrote: > > Hey Rob, could you implement the following: > > x[*][1] > > would be: > > {x[1][1],x[2][1],x[3][1], etc etc etc} > > I don't know what that would do to the e2c translator abilities, but it > would be nice if its possible... > > William Heimbigner > icxcnika at hotpop.com > Get SySlaunch: http://www.geocities.com/icxcnika123/projects.html > Visit the UBoard - Forceful Signups Removed! - > http://uboard.proboards32.com - Threaded discussion, improved searching, > human moderating, graphical smileys, better formatting abilities (now what > else was there...) > Visit my website: http://www.geocities.com/icxcnika123 > > > > -- MrTrick