Re: Your thoughts on two item id methods?

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

Bernie Ryan wrote:
> 
> Al Getz wrote:
> > 
> > Hello there,
> > 
> > 
> > Im looking at something that needs to tell the difference between two
> > different classes of elements in a loop.  The two methods presented
> > here both work, but they work somewhat different.  I'd like to hear
> > any thoughts anyone has on these two methods, as to which one if any
> > seems better and why...
> > 
> > METHOD #1
> > 
> > Atoms are of one class, while sequences are of the other class.
> > Here, we know items of class 1 are atoms, while class 2 items are sequences.
> > This way we can tell the difference between class 1 items and class 2
> > items...
> > 
> > itemlist={ 1,2,3,{8,9},4,{6,7} } --atoms and sequences
> > for k=1 to length(itemlist) do
> >   item=itemlist[k]--atom or seq
> >   if atom(item) then
> >     DoClass1Stuff(item)
> >   else
> >     DoClass2Stuff(item)
> >   end if
> > end for
> > 
> > 
> > METHOD #2
> > 
> > Atoms will be in a sequence where the first element is zero, while
> > the other class will always have a '1' as first element with the real
> > data in elements 2 and above.  Thus, class 1 elements start with a zero
> > and class 2 elements start with a 1...
> > 
> > itemlist={ {0,1},{0,2},{0,3},{1,8,9},{0,4},{1,6,7} } --all sequences
> > 
> > for k=1 to length(itemlist) do
> >   item=itemlist[k]--always a sequence
> >   if item[1] then
> >     DoClass2Stuff(item)
> >   else
> >     DoClass1Stuff(item)
> >   end if
> > end for
> > 
> > I'm not that worried about the increase in memory space taken by
> > the second method.
> > In each itemlist there will be approx the same number of class 1 items
> > as there are class 2 items.
> > 
> 
> Al:
>   Why can't you doing this:
> 
> itemlist={ 1,2,3,{8,9},4,{6,7} } --atoms and sequences
> 
> for k=1 to length(itemlist) do
>   if atom(itemlist[k]) then
>     DoClass1Stuff(itemlist[k])
>   else
>     DoClass2Stuff(itemlist[k])
>   end if
> end for
>  
> 
> Bernie
> 
> My files in archive:
> w32engin.ew mixedlib.e eu_engin.e win32eru.exw
> 
> Can be downloaded here:
> <a
> href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a>
> 

Hi Bernie,

Yes, that might help too, but the main decision here is to go with
the data structure of Method 1 or of Method 2.  Once the routines are
written they will depend on the data structure so it's a tough decision.
It would be hard to change later on.

Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

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

Search



Quick Links

User menu

Not signed in.

Misc Menu