1. Distinction between string and sequence
- Posted by Kondor Attila <euflev at dpg.hu> Dec 22, 2004
- 457 views
I'd like print sequences and strings. If the members in sequence are smaller then ascii_max the sequence prinoutt and string printout are equal. ----------
include Misc.e
procedure the_end() puts(1, "\nPress Enter to continue\n") if atom(gets(0)) then end if abort(0) end procedure
without warning - sequence seq
seq={{52,49,53},"415"}
pretty_print(1, seq, {2,5})
puts(1,"\n")
the_end() }}}
-------
The result: { "415" <
Attila Kondor }}}
2. Re: Distinction between string and sequence
- Posted by Greg Haberek <ghaberek at gmail.com> Dec 22, 2004
- 458 views
- Last edited Dec 23, 2004
> seq={{52,49,53},"415"} > "415" <-- I'd like hier to see: {52,49,53} > "415" Unfortunately, {52,49,53} and "415" are the same internally (to the interpreter). You have to determine when a sequence is a string and when it is plain data. You'd have to do something like this:
sequence a a = {52,49,53} print(1, a) -- outputs {52,49,53} printf(1, "%s", {a}) -- outputs "415"
3. Re: Distinction between string and sequence
- Posted by Vincent <darkvincentdude at yahoo.com> Dec 22, 2004
- 428 views
- Last edited Dec 23, 2004
Greg Haberek wrote: > > > seq={{52,49,53},"415"} > > > "415" <-- I'd like hier to see: {52,49,53} > > "415" > > Unfortunately, {52,49,53} and "415" are the same internally (to the > interpreter). You have to determine when a sequence is a string and > when it is plain data. You'd have to do something like this: > > }}} <eucode> > sequence a > > a = {52,49,53} > > print(1, a) -- outputs {52,49,53} > printf(1, "%s", {a}) -- outputs "415" > > </eucode> {{{ > > This should do it also...
-- Disiguish a string from a sequence include get.e include misc.e constant COUT = 1 integer halt sequence elem elem = {{52,49,53},"415"} sequence val val = value(elem[1]) sequence str str = {val[2], elem[2]} print(COUT, reverse(str)) halt = wait_key()
Vincent