Re: lists in breve
"Anand Veeraswamy" <[email protected]> Sat, 3 Sep 2005 18:58:59 +0100
| Newsgroups | gmane.comp.breve |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--===============66226851977298118==
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_006E_01C5B0B9.8AAE1530"
This is a multi-part message in MIME format.
------=_NextPart_000_006E_01C5B0B9.8AAE1530
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
It could be possible that there is a circular reference in my coding =
though I am unable to detect this right now. I am implementing path =
finding algorithms and I might feel the need to use circular references =
in my lists. So is there a way to neglect the compilers check for =
circular redundancy checks?? I mean if there is a circular reference I =
would like to detect it myself and not have the compiler do it. Is this =
possible??
Also is it possible to assign individual elements in a nested list in =
the form of=20
tempList {0}{0} =3D 1.
tempList{0}{1} =3D 2.
tempList{1}{0} =3D 3.
tempList{1}{1} =3D4.
which will give tempList =3D { {1,2}, {3,4} }.
Anand.
----- Original Message -----=20
From: jon klein=20
To: [email protected]=20
Sent: Saturday, September 03, 2005 6:26 PM
Subject: Re: [breve] lists in breve
On Sep 3, 2005, at 1:15 PM, Anand Veeraswamy wrote:
Hi,
I have 2 issues while using lists in breve.
1) If I have a nested list like tempList=3D{ {1,2}, {3,4} }
I am able to access individual elements of this list =
using tempList{0}{0} or tempList{0}{1} which will give 1 and 2 =
respectively
But I am unable to create a nested list using the =
following commands=20
tempList{0}{0} =3D 1
tempList{0}{1} =3D 2
when I try using the above 2 commands I get an error =
saying that the "list index 0 is out of bounds"
Why does this happen??=20
=20
Is there any other method to create nested lists?? I =
need to assign the individual elements of the nested list.
I think the problem is that breve doesn't know that tempList{0} is a =
list, since there is nothing there yet. Try doing this:
tempList{0} =3D {}. # initialize to an empty list
tempList{0}{0} =3D 1. # now assign the elements.
2) In order to over come this issue I started using the push list =
function
I create 2 lists like .....
=20
tempList1 =3D { LifePatch (0A458E38) , LifePatch =
(0A459080) } # LifePatch is the name of the class which inherits the =
Patch class
tempList2 =3D { LifePatch (0A458E38) , LifePatch =
(0A458760) } # The elements of the list are Patches
=20
Then I use the push function in this way
push tempList1 onto pathList. =20
push tempList2 onto pathList.
Now when I check the pathList I get something like this
pathList =3D { { LifePatch (0A458E38) , LifePatch =
(0A458760) }, [circular list reference 0A49FED0] }
What is Circular list reference??=20
Actually I am using a while loop to implement the above =
coding
while(length3>=3D0): {
i=3D0.
tempList2{i} =3D tempList1{0}.=20
i++. =20
tempList2{i} =3D neighborList{length3}.
push tempList2 onto pathList. # At each iteration =
the list created is pushed=20
length3--.
}
A circular list reference means that a reference to the list itself is =
embedded in the list somehow! Here's the simplest way this might =
happen:
myList{ 0 } =3D myList.
I don't see exactly where it's happening in your code because I don't =
know the exact contents of the lists you're manipulating, but it's =
likely that something similar is happening there.
Circular list references can be useful if, for example, you're =
encoding some sort of directed graph, but most of the time they're not =
used and can cause infinite loops or other problems as you attempt to =
use the list.
- jon klein
-------------------------------------------------------------------------=
-----
_______________________________________________
breve mailing list
[email protected]
http://lists.spiderland.org/mailman/listinfo/breve
------=_NextPart_000_006E_01C5B0B9.8AAE1530
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2722" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY=20
style=3D"WORD-WRAP: break-word; khtml-nbsp-mode: space; =
khtml-line-break: after-white-space"=20
bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>It could be possible that there is a =
circular=20
reference in my coding though I am unable to detect this right now. I am =
implementing path finding algorithms and I might feel the need to use =
circular=20
references in my lists. So is there a way to neglect the compilers check =
for=20
circular redundancy checks?? I mean if there is a circular reference I =
would=20
like to detect it myself and not have the compiler do it. Is this=20
possible??</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Also is it possible to assign =
individual elements=20
in a nested list in the form of </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
tempList=20
{0}{0} =3D 1.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
tempList{0}{1} =3D 2.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
tempList{1}{0} =3D 3.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =20
tempList{1}{1} =3D4.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>which will give tempList =3D { {1,2}, =
{3,4}=20
}.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Anand.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>----- Original Message ----- </DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV=20
style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
<A [email protected] href=3D"mailto:[email protected]">jon =
klein</A>=20
</DIV>
<DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
[email protected]=20
href=3D"mailto:[email protected]">[email protected]</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Saturday, September 03, =
2005 6:26=20
PM</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Re: [breve] lists in =
breve</DIV>
<DIV><BR></DIV><BR>
<DIV>
<DIV>On Sep 3, 2005, at 1:15 PM, Anand Veeraswamy wrote:</DIV><BR=20
class=3DApple-interchange-newline>
<BLOCKQUOTE type=3D"cite">
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have 2 issues while using lists =
in=20
breve.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>1) If I have a nested list =
like=20
tempList=3D{ {1,2}, {3,4} }</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
I am able to access individual =
elements of this list using tempList{0}{0} or tempList{0}{1} which =
will give=20
1 and 2 respectively</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
But I am unable to create a =
nested=20
list using the following commands </FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbs=
p; =20
tempList{0}{0}</FONT> <FONT face=3DArial size=3D2>=3D =
1</FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbs=
p; =20
tempList{0}{1} =3D 2</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
when I try using the above 2 =
commands=20
I get an error saying that the "list index 0 is out of =
bounds"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
Why does this happen?? =
</FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbs=
p; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
Is there any other method to =
create=20
nested lists?? I need to assign the individual elements of the =
nested=20
list.</FONT></DIV></BLOCKQUOTE>
<DIV><BR class=3Dkhtml-block-placeholder></DIV>
<DIV>I think the problem is that breve doesn't know that tempList{0} =
is a=20
list, since there is nothing there yet. Try doing this:</DIV>
<DIV><BR class=3Dkhtml-block-placeholder></DIV>
<DIV>tempList{0} =3D {}. # initialize to an empty list</DIV>
<DIV>tempList{0}{0} =3D 1. # now assign the elements.</DIV>
<DIV><BR class=3Dkhtml-block-placeholder></DIV><BR>
<BLOCKQUOTE type=3D"cite">
<DIV></DIV>
<DIV><FONT face=3DArial size=3D2>2) In order to over come this issue =
I started=20
using the push list function</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
I create 2 lists like .....</FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbs=
p;=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
tempList1 =3D { LifePatch (0A458E38) , LifePatch=20
(0A459080) } # LifePatch is the name of the class which =
inherits=20
the Patch class</FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbs=
p;=20
tempList2 =3D { LifePatch (0A458E38) , LifePatch =
(0A458760) } # The=20
elements of the list are Patches</FONT></DIV>
<DIV><FONT face=3DArial=20
=
size=3D2> &nbs=
p; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
Then I use the push function in this=20
way</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
push tempList1 onto=20
=
pathList. &nbs=
p;=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
push tempList2 onto pathList.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
Now when I check the pathList I get something =
like=20
this</FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
pathList =3D { { LifePatch (0A458E38) , LifePatch =
(0A458760) }, <U><STRONG>[circular list reference 0A49FED0]=20
</STRONG></U>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
<STRONG>What is Circular list reference??=20
</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
Actually I am using a while loop to implement the =
above=20
coding</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
while(length3>=3D0):=20
=
{<BR> &n=
bsp; =20
=
i=3D0.<BR> &nb=
sp; =20
tempList2{i} =3D tempList1{0}. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2> =
=20
=20
=
i++. <BR>  =
; =20
tempList2{i} =3D neighborList{length3}.</FONT><FONT face=3DArial=20
=
size=3D2><BR> =
=20
push tempList2 onto pathList. # At each iteration the list =
created is=20
pushed=20
=
<BR> &nb=
sp; =20
=
length3--.<BR>  =
; =20
}</FONT></DIV>
<DIV><BR =
class=3Dkhtml-block-placeholder></DIV></BLOCKQUOTE><BR></DIV>
<DIV>A circular list reference means that a reference to the list =
itself is=20
embedded in the list somehow! Here's the simplest way this might =
happen:</DIV>
<DIV><BR class=3Dkhtml-block-placeholder></DIV>
<DIV>myList{ 0 } =3D myList.</DIV>
<DIV><BR class=3Dkhtml-block-placeholder></DIV>
<DIV>I don't see exactly where it's happening in your code because I =
don't=20
know the exact contents of the lists you're manipulating, but it's =
likely that=20
something similar is happening there.</DIV>
<DIV><BR class=3Dkhtml-block-placeholder></DIV>
<DIV>Circular list references can be useful if, for example, you're =
encoding=20
some sort of directed graph, but most of the time they're not used and =
can=20
cause infinite loops or other problems as you attempt to use the =
list.</DIV>
<DIV><BR class=3Dkhtml-block-placeholder></DIV>
<DIV>- jon klein</DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>breve =
mailing=20
=
list<BR>[email protected]<BR>http://lists.spiderland.org/mailman/listi=
nfo/breve<BR></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_006E_01C5B0B9.8AAE1530--
--===============66226851977298118==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
breve mailing list
[email protected]
http://lists.spiderland.org/mailman/listinfo/breve
--===============66226851977298118==--