RE: Possible feature for new Euphoria-version
- Posted by Philip Deets <philip1987 at hotmail.com> Jan 13, 2004
- 440 views
Robert Craig wrote: > > > 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 > > My preference is number 2. But my vote shouldn't count as much as the other's votes because I'm not an experienced programmer. I'd like: sequence a, b a = {1,2,3,4,5} b = a[2,1,3..5,1] -- b now equals {2,1,{3,4,5},1} Just my input, Phil