After a fair amount of tests, it seems to me that the "any" option in the "insert at" block of the Variables category, will never match the "last" position in the list.
If this is true, after using a sequence of "any"s, the very *first* item added to the list will always be the *last one*. This is contrary to the random nature of the "any" list position.
The behavour is different in Scratch 1.4/2.0/Flash Player/Java Player. Try it yourself with the "first is last" project.
Last edited by s_federici (2012-05-29 03:26:11)
Offline
You are completely right -- after adding 1500 elements to a list I made in Scratch, the first item (which I had named separately to test it out) was still at the bottom.
I can understand how this has been such an easy error, since the list entry argument is used in many other list blocks and is needed, in those cases, to return a valid item in the list.
The correct way to approach the random inserting would be
insert [x] at (pick random (1) to ((length of [list v]) + (1))) of [list v]
Last edited by LS97 (2012-04-24 12:32:45)
Offline
LS97 wrote:
The correct way to approach the random inserting would be
insert [x] at (pick random (1) to ((length of [list v]) + (1))) of [list v]
Yes, exactly, this is one of the scripts I started using instead of the simple "any".
LS97 wrote:
the first item (which I had named separately to test it out) was still at the bottom.
To keep the scripts (for my students) simple I use indeed a dummy final element. I add it first. Then I use all "any inserted" elements except the very last (dummy) one.
But I'd like a lot to be able to use "any" instead.
Offline
It's worth remembering that if the list adding is a one-time process, the dummy can be added and the beginning and deleted at the end, so that you can use the simple "any" block to access a random element of the list!
Offline
The any drop down works on my computer. What computer do you use? I use a Mac OS X.
In 2012, scientists at the LHC discovered the Higgs boson, which explains the source of the masses of the W+, W-, and Z bosons, as well as fermions.Offline
3sal2 wrote:
The any drop down works on my computer. What computer do you use? I use a Mac OS X.
It's not the dropdown broken, but rather the feature itself. Did you try the experiment above?
Offline
I think arguably this is correct, because putting it at the end isn't really "inserting". However, both the Flash and Java players give the expected result, which might be a sign that the behavior you described was not intended.
Last edited by ManaUser (2012-05-28 17:52:31)
Offline
ManaUser wrote:
However, both the Flash and Java players give the expected result, which might be a sign that the behavior you described was not intended.
I tested it with the "first is last" project, and this is not always the case. As matter of fact, the players (and Scratch 2.0) are more stable, but not completely correct. Instead 1.4 is strictly consistent
Offline