Re: Couple of questions about sequences

new topic     » goto parent     » topic index » view thread      » older message » newer message
Nevla said...
_tom said...

Same answer: an index is an integer.

That I understood. However my question is not being answered: how do I manage efficiently a lookup table that matches named variables with sequence indexes?

Sorry, may reply was terse.

"An index is an integer" means you really are limited to integer expressions to index items in a sequence.

If the sequence is static (meaning no changes in length or shape) then you can make a static list of variables (or constants) with assigned values to index items in a sequence. This is all fixed at the time you write your source-code.

The thing is Euphoria does not allow you to create or destroy variables during the execution of a program. That means you can not have a dynamic list of named variables that index a corresponding dynamic sequence (where the sequence length and shape changes.)

Using the items in a sequence as "variables" used to index another sequence is feasible. The resulting code will likely be messy.

To have the convenience of using some kind of name for indexing means you need a technique that allows you to use an a text string as a key to access a record. Look at the EDS (Euphoria Data Base) or std/map.e for this kind of service. The other example is 3tables.zip (from the RDS Archive) which shows you a simple way to synchronize a sequence of keys with a sequence of records.

Euphoria does not have a syntax trick that lets you use named variables for indexing and then have everything adjust automatically as the sequence changes length and shape.

If this does not answer your question then I need a sample of pseudo-code that demonstrates what you are trying to do.

_tom

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

Search



Quick Links

User menu

Not signed in.

Misc Menu