Alice Community

Alice Community (
-   Bugs and Troubleshooting (
-   -   Problem removing item from the end of a list. (

DrJim 02-22-2007 02:37 PM

Problem removing item from the end of a list.
1 Attachment(s)
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?

chuck 02-22-2007 07:54 PM

You've found a software bug -- Here's a quick fix.
1 Attachment(s)
Hello Dr. Jim,

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

I looked at the error code and found that an [I]index out of bounds [/I]exception was being generated. I believe the underlying code is trying to delete item [I][B]N [/B][/I]from a list with [I][B]N [/B][/I]items. Since the list numbering starts with [I][B]0, [/B][/I]it should be trying to delete item [I][B]N-1 [/B][/I]from a list with [I][B]N [/B][/I]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 [I][B][size of list] – 1[/B][/I]. See the modified attached world.

Kelli 03-16-2010 01:55 PM

Bug - remove from end of list
I came across this bug today. I'm glad it's been noted, and I hope it will be resolved in future versions.

All times are GMT -5. The time now is 01:25 AM.

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