RE: representation problem

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

There is no distinguishable difference between the 2 except how you read 
it.

a = {65,83,67,73,73} = b = "ASCII"

If it's data generated by your program, then you can use the first or 
last element of the sequence as a designator.

I'd use the last element, with 0 for strings and 1 for byte data.

a = {65,83,67,73,73,1} -- bytes
b = "ASCII"&0 -- string

Chris

gwalters at sc.rr.com wrote:
> I'm having trouble with this problem. How do you destinguish between 
> these.
> They have the same length and they are both sequences but I need to 
> treat
> them differently. for a i need to loop through and print each number but 
> for
> b i need to print the string. I'm trying to modify Buddy Hyllberg data 
> dump
> but am lost in this problem.
> 
> sequence a,b
> 
> a = {1,2,3,4}
> b = "1234"
> 
> printf(1,"len a = %d  len b = %d\n",{length(a),length(b)})
> 
> if atom(a) then puts(1,"a is an atom\n") else puts(1,"a is a seq\n") end 
> if
> 
> if atom(b) then puts(1,"b is an atom\n") else puts(1,"b is a seq\n") end 
> if
> 
> 
> b = gets(0)
> 
> george
> 
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu