1. Such a simple thing, yet

I know I already asked this question before, the concept, but I still hav=
e
trouble.  To me, this is the only drawback of having only type sequences.=


sequence d
d =3D date()
puts(1,d[1])

d[1] =3D 98, which is the ascii value of 'b'.  It prints b on the screen.=
  I
don't want it to print b, I want it to print 98.  A simple 98.  How can I=

do this?

Another problem.  This is an atom, atoms are indivisible.  But what if I
want to append the digits 19 before 98?  So make it print 1998?  I could
add 1900, but that seems crude.

--Alan
 =

new topic     » topic index » view message » categorize

2. Re: Such a simple thing, yet

Such a simple thing, yes.

printf(1,"%d",{d[1]})

As far as the other, what is the problem in being crude? <G>

Alan Tu wrote:

> I know I already asked this question before, the concept, but I still have
> trouble.  To me, this is the only drawback of having only type sequences.
>
> sequence d
> d = date()
> puts(1,d[1])
>
> d[1] = 98, which is the ascii value of 'b'.  It prints b on the screen.  I
> don't want it to print b, I want it to print 98.  A simple 98.  How can I
> do this?
>
> Another problem.  This is an atom, atoms are indivisible.  But what if I
> want to append the digits 19 before 98?  So make it print 1998?  I could
> add 1900, but that seems crude.
>
> --Alan

new topic     » goto parent     » topic index » view message » categorize

3. Re: Such a simple thing, yet

>Such a simple thing, yes.
>
>printf(1,"%d",{d[1]})


Even cleaner would be:

print(1,d[1])

- Puts prints them as a *string* (it interpreters the given sequence as a
one dimension collection of values represention characters based upon the
AscII standard)
- Print prints them as as *data* (it interpreters the given sequence,
showing its structure by using {'s and '}'s, containing a representation of
the values in base 10, sometimes with an scientific exponent (e.g. 4.343e23)

Printf is meant to format data into a character-sequence (1D-seq containing
ascII values) and has special escape characters so you can control the way
the data is interpreterd. Heximal, Decimal, AscII, etc.)

I hope this explenation helps you in understanding the need for different
routines and the way it works, instead of just knowing the prinf () trick or
know how to use ? or print ()

Ralf

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu