1. another newbie question
- Posted by Kat <KSMiTH at PELL.NET> Aug 29, 1999
- 519 views
- Last edited Aug 30, 1999
In the exw trace box, i type "?" , it says "variable name?", i give it "thisseq[1]" , and i expect to see the first nested sequence in thisseq, but instead it tells me "- not defined at this point", even tho the blue box right below has thisseq listed and it's contents showing. What can i be doing wrong? Kat
2. Re: another newbie question
- Posted by David Cuny <dcuny at LANSET.COM> Aug 29, 1999
- 454 views
- Last edited Aug 30, 1999
Kat wondered: > In the exw trace box, i type "?" , it says > "variable name?", i give it "thisseq[1]" You can't query indexed values. -- David Cuny
3. another newbie question
- Posted by Kat <KSMiTH at PELL.NET> Aug 29, 1999
- 432 views
- Last edited Aug 30, 1999
In the following code: while ( sequence(thisseq[nest1]) ) do printf(1,"%s\n",thisseq[nest1]) the exw trace screen colors the brackets around the "nest1" in the first line, but doesn't color them in the second line. And i wanted the whole nested sequence printed as it is shown in the blue screen at the bottom of the trace screen, i didn't want the first char of the first nested sequence. What is it i am not understanding here? Kat, perplexed again.
4. Re: another newbie question
- Posted by "Brian K. Broker" <bkb at CNW.COM> Aug 29, 1999
- 455 views
- Last edited Aug 30, 1999
On Sunday, August 29, 1999 9:10 PM Kat said: > In the following code: > > while ( sequence(thisseq[nest1]) ) do > printf(1,"%s\n",thisseq[nest1]) > > the exw trace screen colors the brackets around the "nest1" in the first > line, but doesn't color them in the second line. And i wanted the whole > nested sequence printed as it is shown in the blue screen at the bottom of > the trace screen, i didn't want the first char of the first nested sequence. > What is it i am not understanding here? > > Kat, > perplexed again. In the reference manual for printf you will find the following: Comments: Watch out for the following common mistake: name="John Smith" printf(1, "%s", name) -- error! This will print only the first character, J, of name, as each element of name is taken to be a separate value to be formatted. You must say this instead: name="John Smith" printf(1, "%s", {name}) -- correct
5. Re: another newbie question
- Posted by Kat <KSMiTH at PELL.NET> Aug 30, 1999
- 461 views
----- Original Message ----- From: Brian K. Broker <bkb at CNW.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Monday, August 30, 1999 1:42 AM Subject: Re: another newbie question > On Sunday, August 29, 1999 9:10 PM Kat said: > > > > In the following code: > > > > while ( sequence(thisseq[nest1]) ) do > > printf(1,"%s\n",thisseq[nest1]) > > > > the exw trace screen colors the brackets around the "nest1" in the first > > line, but doesn't color them in the second line. And i wanted the whole > > nested sequence printed as it is shown in the blue screen at the bottom of > > the trace screen, i didn't want the first char of the first nested > sequence. > > What is it i am not understanding here? > > > > Kat, > > perplexed again. > > In the reference manual for printf you will find the following: > > Comments: Watch out for the following common mistake: > name="John Smith" > printf(1, "%s", name) -- error! > > > This will print only the first character, J, of name, as each element of > name is taken to be a separate value to be formatted. You must say this > instead: > name="John Smith" > printf(1, "%s", {name}) -- correct Actually, this print line prints the first nested sequence of the sequence: printf(1,"%s\n",thisseq) but the colors are not displaying the same, and i wonder if that is a bug in the colorizer or the trace parser? So how do i specify to print the 2nd nested sequence? Kat, still perplexed.
6. Re: another newbie question
- Posted by "Brian K. Broker" <bkb at CNW.COM> Aug 30, 1999
- 450 views
> > In the reference manual for printf you will find the following: > > > > Comments: Watch out for the following common mistake: > > name="John Smith" > > printf(1, "%s", name) -- error! > > > > > > This will print only the first character, J, of name, as each element of > > name is taken to be a separate value to be formatted. You must say this > > instead: > > name="John Smith" > > printf(1, "%s", {name}) -- correct > > Actually, this print line prints the first nested sequence of the sequence: > > printf(1,"%s\n",thisseq) That follows from the above comment... > but the colors are not displaying the same, and i wonder if that is a bug > in the colorizer or the trace parser? Can't help you here (not sure if I follow). Rob? >So how do i specify to print the 2nd nested sequence? printf(1, "%s\n", { thisseq[nest2] } ) -- derived from your previous example -- -- Brian Broker
7. Re: another newbie question
- Posted by Robert Craig <rds at ATTCANADA.NET> Aug 30, 1999
- 453 views
Kat writes: > while ( sequence(thisseq[nest1]) ) do > printf(1,"%s\n",thisseq[nest1]) > > the exw trace screen colors the brackets around the "nest1" > in the first line, but doesn't color them in the second line. The color of a bracket corresponds to the level of nesting of the bracket. The syntax coloring in the trace screen makes the first 2 levels black and the third level yellow. (This is slightly different from the coloring used by ed.ex - I guess I should make them consistent.) Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
8. Re: another newbie question
- Posted by Kat <KSMiTH at PELL.NET> Aug 30, 1999
- 454 views
----- Original Message ----- From: Brian K. Broker <bkb at CNW.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Monday, August 30, 1999 3:59 AM Subject: Re: another newbie question <snip> > Can't help you here (not sure if I follow). Rob? > > >So how do i specify to print the 2nd nested sequence? > > printf(1, "%s\n", { thisseq[nest2] } ) -- derived from your previous > example Given: sentword = {"test1",{"test2","test3"}} printf(1,"%s\n", sentword[1] ) -- prints: t printf(1,"%s\n", {sentword[1]} ) -- prints: test1 printf(1,"%s\n", sentword[2] ) -- prints: test2 I have ordered an epiphany, and i hope it is delivered soon, so i can really grasp exactly and fully all the implications of the preceeding and revel in it, but for now, how do i avoid the following error msg with a test preceeding the print statement? printf(1,"%s\n", {sentword[2]} ) -- prints: sequence found inside character string I don't know how many sequences are inside sentword[2] or how deep the nesting may be inside sentword[2] (or inside sentword[2][3][6], etc). If i must do extensive parsing of the {sentword} before i determine if a section can be printed or sliced or added to, what is the advantage to nesting sequences? And i cannot use sequence() to test with? It seems to me i need another sequence (or another field inside {sentword}.) to record what in {sentword} is a sequence and what is a nested sequence. sentword = {{1,2},"test1",{{1,1,2},"test2","test3",{{1},"test4"}}} Can i trap that Eu error msg and recover from it? Kat, foolishly trying to make it simple. Or is it too simple already?
9. Re: another newbie question
- Posted by Ad Rienks <kwibus at DOLFIJN.NL> Aug 31, 1999
- 454 views
> ----- Original Message ----- > From: Brian K. Broker <bkb at CNW.COM> > To: <EUPHORIA at LISTSERV.MUOHIO.EDU> > Sent: Monday, August 30, 1999 3:59 AM > Subject: Re: another newbie question > =C2=A0 > =C2=A0 > <snip> > =C2=A0 > > Can't help you here (not sure if I follow). Rob? > > > > >So how do i specify to print the 2nd nested sequence? > > > > printf(1, "%s\n", { thisseq[nest2] } ) -- derived from your previo= us > > example > =C2=A0 > Given: > sentword =3D {"test1",{"test2","test3"}} > =C2=A0 > printf(1,"%s\n", sentword[1] ) > -- prints: t > =C2=A0 > printf(1,"%s\n", {sentword[1]} ) > -- prints: test1 > =C2=A0 > printf(1,"%s\n", sentword[2] ) > -- prints: test2 > =C2=A0 > I have ordered an epiphany, and i hope it is delivered soon, so i can= really > grasp exactly and fully all the implications of the preceeding and re= vel in > it, but for now, how do i avoid the following error msg with a test > preceeding the print statement? > =C2=A0 > printf(1,"%s\n", {sentword[2]} ) > -- prints: sequence found inside character string > =C2=A0 > I don't know how many sequences are inside sentword[2] or how deep th= e > nesting may be inside sentword[2] (or inside sentword[2][3][6], etc).= If i > must do extensive parsing of the {sentword} before i determine if a s= ection > can be printed or sliced or added to, what is the advantage to nestin= g > sequences? And i cannot use sequence() to test with? It seems to me i= need > another sequence (or another field inside {sentword}.) to record what= in > {sentword} is a sequence and what is a nested sequence. > =C2=A0 > sentword =3D {{1,2},"test1",{{1,1,2},"test2","test3",{{1},"test4"}}} > =C2=A0 > Can i trap that Eu error msg and recover from it? > =C2=A0 > Kat, > foolishly trying to make it simple. > Or is it too simple already? > -- kat.ex -- shows you the levels of nesting of text sequences -- do with it what you want -- Ad Rienks kwibus at dolfijn.nl include graphics.e -- for get_position procedure put_position(integer level) sequence pos pos =3D get_position() position(pos[1], 9 * (level - 1) + 1) puts(1, "Level: " & sprintf("%d ", level)) end procedure -- set_position procedure slice(sequence s, integer level) if sequence(s) then for n =3D 1 to length(s) do if sequence(s[n]) then level +=3D 1 put_position(level) slice(s[n], level) level -=3D 1 if level > 0 then put_position(level) end if else text_color(BRIGHT_WHITE) puts(1, s[n]) text_color(WHITE) end if end for puts(1, '\n') end if end procedure -- slice sequence sentword sentword =3D {"test1", {"test2", {"test3", "test4"}}, "test5"} slice(sentword, 0) | Gratis e-mail en meer: http://www.dolfijn.nl/ | Een product van Ilse: http://www.ilse.nl/
10. Re: another newbie question
- Posted by bytebrain <bytebrain at MINDSPRING.COM> Aug 30, 1999
- 475 views
- Last edited Aug 31, 1999
-------Phoenix-Boundary-07081998- Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: Quoted-printable Hi Kat, you wrote on 8/30/99 1:27:32 PM: >. . .but for now, how do i avoid the following error msg with a >test >preceeding the print statement=3F > >printf(1,"%s\n", {sentword[2]} ) >-- prints: sequence found inside character string What about using this function to test beforehand: function simpleSequence(object x) -- returns 1 if x is sequence w/ no subsequences -- 0 otherwise if atom(x) then return 0 else for element =3D 1 to length(x) do if not atom(x[element]) then return 0 end if end for end if return 1 end function > . . . It seems to me i need >another sequence (or another field inside {sentword}.) to >record what in >{sentword} is a sequence and what is a nested sequence. Try mapping it with something like this: global function objectOverview(object x) -- if x is an atom, the return sequence will be an atom (0), -- else it will be a sequence of one letter codes corresponding -- to the top level elements of sequence x: -- 0 =3D element is an atom -- 1 =3D element is a simple sequence -- 2 =3D element is a sequence containing further sequences -- The first element of the map returned will be the length of the -- sequence x, so that you have: -- { <length>, <first element category>, <second element category>, . . . } -- -- EX: objectOverview( {5, "hi!", 78, { 9, {5} }, {}, {{}} } ) -- should return {6, 0, 1, 0, 2, 1, 2} -- object map integer subElement if atom(x) then map =3D 0 else map =3D {length(x)} for element =3D 1 to length(x) do if atom(x[element]) then map &=3D 0 else map &=3D 1 subElement =3D 1 while subElement <=3D length(x[element]) do if sequence(x[element][subElement]) then map[length(map)] =3D 2 exit end if subElement +=3D 1 end while end if end for end if return map end function -------------------------------------------------------------- -------------------------------------------------------------- If the above is overkill or going off on a tangent (or both), my apologies. If the above is underkill, you could alter objectOverview() to recurse into the object and create a map complete to whatever level you wanted. Parsing that sort of map, however, might be just about as complex as parsing the sequence to begin with. Craig -------bytebrain at mindspring.com-------- "Obvious" is the most dangerous word in mathematics. --Eric Temple Bell -------Phoenix-Boundary-07081998---
11. Re: another newbie question
- Posted by bytebrain <bytebrain at MINDSPRING.COM> Aug 30, 1999
- 490 views
- Last edited Aug 31, 1999
-------Phoenix-Boundary-07081998- Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: Quoted-printable Oops. In my last message, this: > >global function objectOverview(object x) >-- if x is an atom, the return sequence will be an atom (0), should be this: global function objectOverview(object x) -- if x is an atom, the return VALUE will be an atom (0), Sorry. Craig ----bytebrain at mindspring.com---- Flappity, floppity, flip The mouse on the mobius strip; The strip revolved, The mouse dissolved In a chronodimensional skip. -- Anonymous -------Phoenix-Boundary-07081998---
12. Re: another newbie question
- Posted by "Glen T. Brown" <gbrown at SAUDIONLINE.COM.SA> Aug 31, 1999
- 446 views
Hi Kat, Hope this helps. > I have ordered an epiphany, and i hope it is delivered soon, so i can really > grasp exactly and fully all the implications of the preceeding and revel in > it, but for now, how do i avoid the following error msg with a test > preceeding the print statement? According to the Euphoria Programming Language Reference Manual: --- 2.1.1 Atoms and Sequences All data objects in Euphoria are either atoms or sequences. An atom is a single numberic value. A sequence is a collection of numeric values. --- Now to me this says that a SEQUENCE is really just a collection of ATOMs all strung together. Also indicated by the fact that while tracing a program any variable that is a 'string' (or collection of readable letters) is displaied as its ASCII value. RDS was thoughtful enough to supply the letter equivelant of any number that is a printable ASCII character along with that number. Now, your problem seems to be getting a handle on nested sequences. Another way to look at a sequence is that it is a one-dimentional array of atoms. With that in mind, a nested sequence is just a multi-dimentional array of atoms. >Given: >sentword = {"test1",{"test2","test3"}} > >printf(1,"%s\n", sentword[1] ) >-- prints: t Given the examples that you provided. The 't' that you ended up with is the first 't' from "test1". You only got the 't' because 'sentword[1]' by itself indicates to Euphoria that you are only interested in an atom. >printf(1,"%s\n", {sentword[1]} ) >-- prints: test1 What you get here is obviously "test1". The '{' and '}' indicate to Euphoria that you are interested in the sequence that is at subscript 1 >printf(1,"%s\n", sentword[2] ) >-- prints: test2 This one is probably where you are getting really confused. I have been messing with it a little and I find it slightly confusing too. If you do some more testing you will find that : printf(1,"%s\n", {sentword[2] }) Generates this error: sequence found inside character string If I understand this correctly with this expression Euphoria is expecting to find a single sequence in subscript two when there is in reality two sequences inside sequence two. {"test2","test3"} This is two sequences of characters. On first glance it would seem that printing sentword[2] would give you a 't' like it did with sentword[1]. However, it looks like since sentword[2] is a subscript itself that Euphoria picks up the first element of the substring. That being "test2". I am reading this as I go and I am starting to confuse myself. I think that we need to look at this problem the way that Euphoria is looking at it. What Euphoria actually sees is more along the lines of : I thik this is a little more obvious. There is a nesting of sequences that is three deep. I think that the following can be extrapilated from this. printfing -- sentword[1] gives the first element that it finds in the first subscript. 116 printfing -- {sentword[1]} gves the first sequence that it finds in the first subscript. 116,101,115,116,49 printfing -- sentword[2] gives the first element that it finds in the second subscript. {116,101,115,116,50} which just happens to be a sequence. printfing -- {sentword[2]} gives an error because it is looking for a sequence and finds a sequence of sequences because you are trying to format it as a string and Euphoria sees a string of strings which is evidently not valid. printfing -- sentword[2][1] gives the first element of the first sub-subscript of the second subscript. 116 printfing -- {sentword[2][1]} gives the sequence that it finds in first sub-subscript of the second subscript. 116,101,115,116,50 Now, after all that. I hope that this at least makes some sense to someone. I am hoping that it makes sense to Kat because that is who it was meant for. I would recomend reading Part I chapter 2 of the Reference Manual. I think that it goes over this stuff quite well. As I am trying to explain this I am reading the manual and playing with Euphoria in another window. Gets a little confusing after a while. Good luck on the arrival of your epiphany. I hope that it is everything that you are expecting. > Kat, > foolishly trying to make it simple. > Or is it too simple already? Till next time. L8R Glen
13. Re: another newbie question
- Posted by Kat <KSMiTH at PELL.NET> Aug 31, 1999
- 449 views
----- Original Message ----- From: Glen T. Brown <gbrown at SAUDIONLINE.COM.SA> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Tuesday, August 31, 1999 9:21 AM Subject: Re: another newbie question <snip> > Now, your problem seems to be getting a handle on nested sequences. Yes,, it seems to me that Eu could either print the top level of that nested sequence array, or return an error msg listing the number of nested sequences using the sequence() function. Like, 0 = no sequence, 1 = a sequence (like it does now), 2 = two sequences found, etc.. > Another way to look at a sequence is that it is a one-dimentional array of > atoms. Yes, i am exploring why it doesn't cross my mind to use atom() to verify sequence presences. > With that in mind, a nested sequence is just a multi-dimentional array of > atoms. > > >Given: > >sentword = {"test1",{"test2","test3"}} > > > >printf(1,"%s\n", sentword[1] ) > >-- prints: t > > Given the examples that you provided. The 't' that you ended up with is > the first 't' from "test1". You only got the 't' because 'sentword[1]' by > itself indicates to Euphoria that you are only interested in an atom. > > >printf(1,"%s\n", {sentword[1]} ) > >-- prints: test1 > > What you get here is obviously "test1". The '{' and '}' indicate to > Euphoria that you are interested in the sequence that is at subscript 1 > > >printf(1,"%s\n", sentword[2] ) > >-- prints: test2 Actually, this makes some sense, altho it doesn't appear to be documented, i wasn't expecting it to work. It's that "element" thing at work. > This one is probably where you are getting really confused. I have been > messing with it a little and I find it slightly confusing too. If you do > some more testing you will find that : > > printf(1,"%s\n", {sentword[2] }) > > Generates this error: sequence found inside character string Right, this is where a returned value in sequence() would be handy. I mean, that is the function to use to determine it's a sequence, so it could also determine what sort of sequence it is. Oh well, that's why Craig and Ad and you are on this listserv. > If I understand this correctly with this expression Euphoria is expecting to > find a single sequence in subscript two when there is in reality two > sequences inside sequence two. {"test2","test3"} This is two sequences of > characters. > > On first glance it would seem that printing sentword[2] would give you a 't' > like it did with sentword[1]. However, it looks like since sentword[2] is a > subscript itself that Euphoria picks up the first element of the substring. > That being "test2". Yes, it seems like a fortunate anomaly in a way. I also found myself using the word "element" to describe what was going on. > Good luck on the arrival of your epiphany. I hope that it is everything > that you are expecting. Thanks. I downloaded the latest FreePascal, only to see that i'd still be spending most of my time coding for memory management routines. I am wondering if i should stay with the same form of storage in strings i used in pascal tho, keeping all the tags i already have from the yrs of coding the database in that form. I mean, if all the tests for atom() take more time than the find_start_tag-find_end_tag-copy_substring in a single string, then nesting sequences really is a drawback, due to lack of ready accessability and access speed. One form of var access i have gotten spoiled on is what i use in pascal and mirc: %rootvarname.nest1name.nest2name . In pascal they can be built/extended with some slight trouble using pointers, in mirc it's easy (but slow, even slower is $gettok()). Oh well, may be time for a function to mimic that in Eu now. Kat, thankful this forum exists.