RE: Possible feature for new Euphoria-version

new topic     » topic index » view thread      » older message » newer message

> -----Original Message-----
> From: Robert Craig [mailto:rds at RapidEuphoria.com]
> Subject: Re: Possible feature for new Euphoria-version
>
>
>
> 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.

Or as alternative ...

     s = {100, 200, 300, 400, 500}
     s[1,5,3] is {100, 500, 300}

> 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.

Or as alternative ...

     s."Tommy" = 99

> Which approach is best? If you choose one, you'll
> eliminate the possibility of doing the others.

Well at least any of them will be an improvement, and the "eliminated" ones
are still possible through slower methods.

--
Derek

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu