Re: another newbie question
- Posted by bytebrain <bytebrain at MINDSPRING.COM> Aug 30, 1999
- 473 views
-------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---