Re: Possible feature for new Euphoria-version
- Posted by Robert Craig <rds at RapidEuphoria.com> Jan 09, 2004
- 408 views
Tommy Carlier wrote: > sequence seq > seq = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} > sequence b > b = {2, 2} > integer a > a = seq[b] > > This way you can also pass and return multiple indices to and from > procedures and functions. There are at least three logical ways that you might define subscripting of a sequence with a sequence. 1. Your way (above). The sequence used as a subscript would contain a series of subscripts to be applied. This fills a logical gap in subscripting, since currently the number of levels of subscripting is fixed at compile-time. You could use this for reading and writing. 2. sequence s s = {100, 200, 300, 400, 500} s[{1,5,3}] is {100, 500, 300} The subscript would let you randomly select a bunch of elements for reading or writing. 3. sequence s s[1] = 7 s["Tommy"] = 99 s["Carlier"] = 0 s["Carlier"] += 1 ? s["Tommy"] * s["Carlier"] The Euphoria implementer might set up a hash table internally. Whenever you assigned to a previously nonexistent element, the implementation would create a new element for you. This would be good for symbol tables, databases etc. Which approach is best? If you choose one, you'll eliminate the possibility of doing the others. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com