Discussion:
lists in breve
Anand Veeraswamy
2005-09-03 17:15:52 UTC
Permalink
Hi,

I have 2 issues while using lists in breve.

1) If I have a nested list like tempList={ {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
tempList{0}{0} = 1
tempList{0}{1} = 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??

Is there any other method to create nested lists?? I need to assign the individual elements of the nested list.

2) In order to over come this issue I started using the push list function
I create 2 lists like .....

tempList1 = { LifePatch (0A458E38) , LifePatch (0A459080) } # LifePatch is the name of the class which inherits the Patch class
tempList2 = { LifePatch (0A458E38) , LifePatch (0A458760) } # The elements of the list are Patches

Then I use the push function in this way

push tempList1 onto pathList.
push tempList2 onto pathList.

Now when I check the pathList I get something like this
pathList = { { LifePatch (0A458E38) , LifePatch (0A458760) }, [circular list reference 0A49FED0] }

What is Circular list reference??

Actually I am using a while loop to implement the above coding

while(length3>=0): {
i=0.
tempList2{i} = tempList1{0}.
i++.
tempList2{i} = neighborList{length3}.
push tempList2 onto pathList. # At each iteration the list created is pushed
length3--.
}

Please help me resolve the above issues.

Thanks and regards,
Anand.
jon klein
2005-09-03 17:26:48 UTC
Permalink
Post by Anand Veeraswamy
Hi,
I have 2 issues while using lists in breve.
1) If I have a nested list like tempList={ {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
tempList{0}{0} = 1
tempList{0}{1} = 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??
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} = {}. # initialize to an empty list
tempList{0}{0} = 1. # now assign the elements.
Post by Anand Veeraswamy
2) In order to over come this issue I started using the push list function
I create 2 lists like .....
tempList1 = { LifePatch (0A458E38) , LifePatch
(0A459080) } # LifePatch is the name of the class which inherits
the Patch class
tempList2 = { LifePatch (0A458E38) , LifePatch
(0A458760) } # The elements of the list are Patches
Then I use the push function in this way
push tempList1 onto pathList.
push tempList2 onto pathList.
Now when I check the pathList I get something like this
pathList = { { LifePatch (0A458E38) , LifePatch
(0A458760) }, [circular list reference 0A49FED0] }
What is Circular list reference??
Actually I am using a while loop to implement the above coding
while(length3>=0): {
i=0.
tempList2{i} = tempList1{0}.
i++.
tempList2{i} = neighborList{length3}.
push tempList2 onto pathList. # At each iteration
the list created is pushed
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 } = 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
Anand Veeraswamy
2005-09-03 17:58:59 UTC
Permalink
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
tempList {0}{0} = 1.
tempList{0}{1} = 2.
tempList{1}{0} = 3.
tempList{1}{1} =4.
which will give tempList = { {1,2}, {3,4} }.

Anand.

----- Original Message -----
From: jon klein
To: ***@spiderland.org
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={ {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
tempList{0}{0} = 1
tempList{0}{1} = 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??

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} = {}. # initialize to an empty list
tempList{0}{0} = 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 .....

tempList1 = { LifePatch (0A458E38) , LifePatch (0A459080) } # LifePatch is the name of the class which inherits the Patch class
tempList2 = { LifePatch (0A458E38) , LifePatch (0A458760) } # The elements of the list are Patches

Then I use the push function in this way

push tempList1 onto pathList.
push tempList2 onto pathList.

Now when I check the pathList I get something like this
pathList = { { LifePatch (0A458E38) , LifePatch (0A458760) }, [circular list reference 0A49FED0] }

What is Circular list reference??

Actually I am using a while loop to implement the above coding

while(length3>=0): {
i=0.
tempList2{i} = tempList1{0}.
i++.
tempList2{i} = neighborList{length3}.
push tempList2 onto pathList. # At each iteration the list created is pushed
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 } = 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
Anand Veeraswamy
2005-09-03 20:48:42 UTC
Permalink
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 -----
From: jon klein
To: ***@spiderland.org
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={ {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
tempList{0}{0} = 1
tempList{0}{1} = 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??

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} = {}. # initialize to an empty list
tempList{0}{0} = 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 .....

tempList1 = { LifePatch (0A458E38) , LifePatch (0A459080) } # LifePatch is the name of the class which inherits the Patch class
tempList2 = { LifePatch (0A458E38) , LifePatch (0A458760) } # The elements of the list are Patches

Then I use the push function in this way

push tempList1 onto pathList.
push tempList2 onto pathList.

Now when I check the pathList I get something like this
pathList = { { LifePatch (0A458E38) , LifePatch (0A458760) }, [circular list reference 0A49FED0] }

What is Circular list reference??

Actually I am using a while loop to implement the above coding

while(length3>=0): {
i=0.
tempList2{i} = tempList1{0}.
i++.
tempList2{i} = neighborList{length3}.
push tempList2 onto pathList. # At each iteration the list created is pushed
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 } = 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

Continue reading on narkive:
Loading...