Alice Community  

Go Back   Alice Community > Alice 2 > Bugs and Troubleshooting

Reply
 
Thread Tools Display Modes
Problem removing item from the end of a list.
Old
DrJim
Guest
 
Status:
Posts: n/a
Question Problem removing item from the end of a list. - 02-22-2007, 01:37 PM

I have a problem using the “remove item from end of <list>“ command - when I try to use it, I always get an error message. The message is similar to that I get when I try to remove something from a list and what I’m trying to remove isn’t there - but it seems like there should always be an item at the end of the list unless the list is completely empty.

The attached world illustrates the problem. As set up, it works fine - the bunny moves from cone to cone around a circle, going to one less cone each loop.

However if I substitute “remove item from end ...” for “remove item from position ...” I get an error - even though these should be equivalent commands. Looks to me like this is a real bug - anyone see anything I’m missing?
Attached Files
File Type: a2w List Test.a2w (347.2 KB, 570 views)
   
Reply With Quote
You've found a software bug -- Here's a quick fix.
Old
chuck
Guest
 
Status:
Posts: n/a
Default You've found a software bug -- Here's a quick fix. - 02-22-2007, 06:54 PM

Hello Dr. Jim,

First, you are right. Remove item from end of (list name) doesn’t work properly – for list variables. It does work for a list created as a ListVisualization object.

I looked at the error code and found that an index out of bounds exception was being generated. I believe the underlying code is trying to delete item N from a list with N items. Since the list numbering starts with 0, it should be trying to delete item N-1 from a list with N items.

(This underlying problem is very reminiscent of things that happen in CS1 the first time students write their own programs to access arrays. I’ve also seen it in professional programs where good programmers simply were off by one. Fortunately, in this case NASA won’t lose a space probe because of a software error.)

Quick fix – to delete an item from the end of a list, delete the item from position [size of list] – 1. See the modified attached world.
Attached Files
File Type: a2w List Test2.a2w (365.1 KB, 571 views)
   
Reply With Quote
Bug - remove from end of list
Old
Kelli
Guest
 
Status:
Posts: n/a
Default Bug - remove from end of list - 03-16-2010, 12:55 PM

I came across this bug today. I'm glad it's been noted, and I hope it will be resolved in future versions.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.