Re: another newbie question

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

----- 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. smile

> 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. smile

Kat,
thankful this forum exists.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu