1. RE: A sequence, by any other name

Hi Jonas,

Jonas  Temple wrote:
> Hello all,
> 
> What I need is a sure-fire way to determine in my program if a sequence 
> is a character sequence versus a sequence of numbers.  I need to 
> determine this dynamically. 
> 
> Maybe this is a basic question?  I dunno.
> 
> Jonas
> 
> 

Offhand there are two ways i can think of to do this.
In general, for any arbitrary sequence there is no way to
distinguish a character from a number that is stored in it.
For example:
n={65}   --these are both exactly
n={'A'}  --the same sequence.

One way to distinguish between the two is to store
a second number along with the original value that tells
your program which type had been stored such as:
n={1,65}  --a number
n={0,'A'} --a character

This is probably the easiest way to emulate a user defined type.

When you go to use the data, your program first checks the first
element of the sub sequence to determine what kind of data is
stored there and acts accordingly.

There is a second method which involves adding
the number 256 to any positive integers in order to
distinguish between characters and integers but it involves
alot more testing on the number before you know what it is.
If your interested i'll post that method next time.
One good point about it is that it doesnt require any more
space to store numbers like the first method does, which
could be a big benefit for large data.

Also keep in mind any kind of home made types are going
to slow the code down somewhat.

Good luck with it.
--Al

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu