Re: lists in breve

"Anand Veeraswamy" <[email protected]> Sat, 3 Sep 2005 21:48:42 +0100
Newsgroups gmane.comp.breve
Message-ID <[email protected]>
This is a multi-part message in MIME format.

--===============036859763516485122==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_00C7_01C5B0D1.4078F710"

This is a multi-part message in MIME format.

------=_NextPart_000_00C7_01C5B0D1.4078F710
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Jon,

Thanks for your help.

I tried all possible ways to copy the lists without getting the cyclic =
list reference.

Finally I used the copylist method and that got rid of the cyclic list =
reference problem.

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_00C7_01C5B0D1.4078F710
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>Jon,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for your help.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I tried all possible ways to copy the =
lists without=20
getting the cyclic list reference.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Finally I used the copylist method and =
that got rid=20
of the cyclic list reference problem.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Anand.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <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>&nbsp;</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>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>1)&nbsp; If I have a nested list =
like=20
    tempList=3D{ {1,2}, {3,4} }</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; I am able to access individual =

    elements of this list using tempList{0}{0} or tempList{0}{1} which =
will give=20
    1 and&nbsp;2 respectively</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; But I am unable to create a =
nested=20
    list using the following commands </FONT></DIV>
    <DIV><FONT face=3DArial=20
    =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
    tempList{0}{0}</FONT>&nbsp;<FONT face=3DArial size=3D2>=3D =
1</FONT></DIV>
    <DIV><FONT face=3DArial=20
    =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
    tempList{0}{1} =3D 2</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 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>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Why does this happen?? =
</FONT></DIV>
    <DIV><FONT face=3DArial=20
    =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 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.&nbsp; 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>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; I create 2 lists like .....</FONT></DIV>
    <DIV><FONT face=3DArial=20
    =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
    </FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; tempList1 =3D { LifePatch (0A458E38) , LifePatch=20
    (0A459080)&nbsp; } # LifePatch is the name of the class&nbsp;which =
inherits=20
    the Patch class</FONT></DIV>
    <DIV><FONT face=3DArial=20
    =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
    tempList2&nbsp;=3D { LifePatch (0A458E38) , LifePatch =
(0A458760)&nbsp; } # The=20
    elements of the list are Patches</FONT></DIV>
    <DIV><FONT face=3DArial=20
    =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; Then I&nbsp;use the push function&nbsp;in this=20
    way</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; push tempList1 onto=20
    =
pathList.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
    </FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; push tempList2 onto pathList.</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; Now when I check the pathList I get something =
like=20
    this</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; pathList =3D { { LifePatch (0A458E38) , LifePatch =

    (0A458760)&nbsp; }, <U><STRONG>[circular list reference 0A49FED0]=20
    </STRONG></U>}</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; <STRONG>What is Circular list reference??=20
    </STRONG></FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; Actually I am using a while loop to implement the =
above=20
    coding</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; while(length3&gt;=3D0):=20
    =
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;=20
    =
i=3D0.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;=20
    tempList2{i} =3D tempList1{0}. </FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
    =
i++.&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
    tempList2{i} =3D neighborList{length3}.</FONT><FONT face=3DArial=20
    =
size=3D2><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
    push tempList2 onto pathList.&nbsp;# At each iteration the list =
created is=20
    pushed=20
    =
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;=20
    =
length3--.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;=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!&nbsp; 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_00C7_01C5B0D1.4078F710--

--===============036859763516485122==
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

--===============036859763516485122==--