Discuss Scratch
- Discussion Forums
 - » Suggestions
 - » Set list block
        
         
- Znapi
 - 
                            
						
						
                            Scratcher
                        
						
						 
500+ posts
Set list block
This might be something that you have never thought about before or even noticed. Where's the block to set a list? I was surprised there wasn't already a topic on it. Maybe it is ancient and lost behind all these new topics about importing lists, and because this can be worked around using other, but slower, methods. We have similar functionality already: go into the editor and right click a list to import a .txt file.
Let's compare list functionality to that of variables, the only other ‘data’ in Scratch
You can get a variable like so:
The set list block
The block I suggest would look like this:
Issues
I could only see one issue with this block. If elements of a list contain spaces themselves(e.g. “hello world”, “how are you?”), then the reporter reports the string “hello world how are you?”. You can no longer tell where each element starts and stops with this string, so doing this:
Workaround
The fact that a workaround exists for this block is an issue in getting support for it. I know that you can get around this by running through each element of one list and adding it to a second list. That is like running through each letter in a variable and adding it to the end of a second variable. It is slower than just setting one equal to the other. This block is also for setting a list to a string, which is why it is so useful, not necessarily one list to another. I know you can parse a string too, but it is slow. Other languages also have this functionality(in fact, I made a mod that adds this block, and it was simple as list1 = list2).
Uses
A set list block would allow for all kinds of creative things to be done with lists. Unfortunately, it most likely won't be used in simple projects, but slightly more complicated projects could benefit from this. It allows for strings to become lists, and gives the current list reporter new meaning because that string(possibly modified) can be loaded back into a list!
Here are some simple examples of ways the block could be used:
                        
                            Let's compare list functionality to that of variables, the only other ‘data’ in Scratch
You can get a variable like so:
(variable1)Then you can set another variable to what the previous block reports, so that the two variables are equivalent.
set [variable2 v] to (variable1)With a list, you get it as a string as shown earlier:
(example list :: list)Now to set another list with it, to make them equivalent.
Something appears to be missing here...All of the other functionality is in line, you can show/hide variables and lists, and lists have all of their extra functionality that makes them a list. Lists are just missing this one thing.
The set list block
The block I suggest would look like this:
set [ v] to [] :: listIt is based around how the current list reporter works. It takes a string and uses it to set the contents of a list. Elements are separated by spaces, like a list reporter reports. Nothing complicated or too new, fits along well with Scratch, and very useful.
Issues
I could only see one issue with this block. If elements of a list contain spaces themselves(e.g. “hello world”, “how are you?”), then the reporter reports the string “hello world how are you?”. You can no longer tell where each element starts and stops with this string, so doing this:
set [list 2 v] to (list 1 :: list) :: listWon't always result in equal lists. It is only in these special cases though. This resulted in me coming up with this block too:
set [list 2 v] to [list 1 v] :: listIt will always produce equal lists, but it isn't too useful.
Workaround
The fact that a workaround exists for this block is an issue in getting support for it. I know that you can get around this by running through each element of one list and adding it to a second list. That is like running through each letter in a variable and adding it to the end of a second variable. It is slower than just setting one equal to the other. This block is also for setting a list to a string, which is why it is so useful, not necessarily one list to another. I know you can parse a string too, but it is slow. Other languages also have this functionality(in fact, I made a mod that adds this block, and it was simple as list1 = list2).
Uses
A set list block would allow for all kinds of creative things to be done with lists. Unfortunately, it most likely won't be used in simple projects, but slightly more complicated projects could benefit from this. It allows for strings to become lists, and gives the current list reporter new meaning because that string(possibly modified) can be loaded back into a list!
Here are some simple examples of ways the block could be used:
set [list 2 v] to (list 1 :: list) :: list
set [list 2 v] to (some list data) :: list
set [list 2 v] to [flashlight crowbar classified-documents] :: list //list contents become "flashlight", "crowbar", "classified-documents"
add (list 1 :: list) to [list 2 v] //lists in lists!
set [tmp v] to (item (1 v) of [list2 v]) :: list //retrieve the list in the list
define i haz list inputz!!11 [list1]
set [tmp v] to (list1) :: list
- Strings could have a whole new meaning. You could set a list to a string so the letters or words get separated from each other. In fact, every string can now be considered a list, similar to how strings work in languages like C, but better. If you had the string “hello”, then if you wanted to remove a letter, you could load it into a list and remove and add letters anywhere! If you had the string “hello world”, loading it into a list would separate each word, which can be removed or added, plus each element, single words, can be a list in itself as mentioned before!
 
- Real two-dimensional lists/lists in lists could finally be made. Currently, this problem is worked around by using a two dimensional array; It has a fixed number of elements, and the element at (x, y) is accessed using (x * total columns + y). A two dimensional list would be able to grow and shrink in both dimensions; it does not have a fixed size. This would be done by making the elements of one list the string representation of other lists!
 
- Lists could be passed through custom block parameters! Because passing lists around as strings would have a bunch of new purposes, lists could be passed into custom blocks through string parameters, and the string could be loaded into a second list that the custom block uses to do its function. Who knows what Scratchers will do with that ability.
 
Last edited by Znapi (May 16, 2015 18:48:45)
- Znapi
 - 
                            
						
						
                            Scratcher
                        
						
						 
500+ posts
Set list block
A mod implementing this
I made a mod for Scratch that implements the set list block, and the other, rather useless one also mentioned. The modded editor(opens in browser) and the modified source(.zip download) can be found here. Go check it out if you want to experiment with this block a little.
Other people looking for this functionality
There are a few forum topics looking for a wider range of string blocks, which can be accomplished with a set list to string block and using methods discussed above.
https://scratch.mit.edu/discuss/topic/115646/ - this one even mentions putting the string in a list!
https://scratch.mit.edu/discuss/topic/106662/
https://scratch.mit.edu/discuss/topic/115640/
There is probably more too…
                        
                            I made a mod for Scratch that implements the set list block, and the other, rather useless one also mentioned. The modded editor(opens in browser) and the modified source(.zip download) can be found here. Go check it out if you want to experiment with this block a little.
Other people looking for this functionality
There are a few forum topics looking for a wider range of string blocks, which can be accomplished with a set list to string block and using methods discussed above.
https://scratch.mit.edu/discuss/topic/115646/ - this one even mentions putting the string in a list!
https://scratch.mit.edu/discuss/topic/106662/
https://scratch.mit.edu/discuss/topic/115640/
There is probably more too…
Last edited by Znapi (May 16, 2015 17:38:18)
- DaSpudLord
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
No support.
                        
                        
                    define set (List1) to (List2)
delete (all v) of (List1)
repeat (length of (List2)
add (item ((length of (List1) + (1)) of (List2)) to (List1)
end
end
- DaSpudLord
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
No support.Whoops… fixed it.define set (List1) to (List2)
delete (all v) of (List1)
repeat (length of (List2)
add (item ((length of (List1) + (1)) of (List2)) to (List1 :: lists) :: lists
end
Last edited by DaSpudLord (May 12, 2015 13:30:09)
- ChocolatePi
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
Support!
I also wish we had first-class lists, but that might be beyond the scope of Scratch…
                        
                        
                    I also wish we had first-class lists, but that might be beyond the scope of Scratch…
- Znapi
 - 
                            
						
						
                            Scratcher
                        
						
						 
500+ posts
Set list block
You can't pass lists as custom block parameters. A custom block like that would require modifying the .json. I talked about that workaround in my post too.define set (List1) to (List2)
delete (all v) of (List1)
repeat (length of (List2)
add (item ((length of (List1)) + (1)) of [List2 v]) to [List1 v]
end
Before someone says it, I know that you can get around this by running through each element of one list and adding it to a second list. That is like running through each letter in a variable and adding it to the end of a second variable. It is slower than just setting one equal to the other.
- DaSpudLord
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
Thanks, I was writing this from my tablet and was kinda in a rush, so I had a couple problems.define set (List1) to (List2)
delete (all v) of (List1)
repeat (length of (List2)
add (item ((length of (List1)) + (1)) of [List2 v]) to [List1 v]
end
- DaSpudLord
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
There we go. Sorry about the multiple posts, but I can't edit my old ones cuz this is a new account.No support.Whoops… fixed it.define set (List1) to (List2)
delete (all v) of (List1)
repeat (length of (List2)
add (item ((length of (List1)) + (1)) of (List2)) to (List1)
end
- FalconGunner99
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
define set (List1) to (List2)
delete (all v) of (List1)
repeat (length of (List2)
add (item ((length of (List1)) + (1)) of (List2)) to (List1)
end
I think we all know that that is too complicated to be a reasonable workaround for newer scratchers.
I support, some better list blocks would be great.
I also think a
add () to list [ v] () times :: list
block could be nice, although it is much easier that the other blocks to work around.
Last edited by FalconGunner99 (May 12, 2015 16:30:48)
- DaSpudLord
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
Now that is WAY too easy of a workaround-define set (List1) to (List2)
delete (all v) of (List1)
repeat (length of (List2)
add (item ((length of (List1)) + (1)) of (List2)) to (List1)
end
I think we all know that that is too complicated to be a reasonable workaround for newer scratchers.
I support, some better list blocks would be great.
I also think aadd () to list [ v] () times :: list
block could be nice, although it is much easier that the other blocks to work around.
define add (String) to (List) (Times) times
repeat (Times)
add (String) to (List)
Last edited by DaSpudLord (May 12, 2015 16:33:07)
- DaSpudLord
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
Also, how would the string be separated into separate items in a list? Or would it only fill a single item in the list? If so, then which item in the list would it fill? The reason we don't have this is because a list is a variable with multiple slots for numbers/strings. Instead, we have
                        
                        
                    replace item (1 v) of [list v] with []You can't just set a list to a single value because it can have MULTIPLE values.
- Birdlegs
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
Well, the thing here is that 
here:
Also, when would you really need that? It wouldn't be useful all that often. Besides, you can't have everything done yourself
 I personally think the workaround is really cool. And Scratchers have to learn to work within limits, and not having that block is one of them. As was said in an awesome article I once read, paraphrased because my memory is in no way adamant, “I like limits. Limits force us to come up with new ideas to break boundaries.” So yeah 
 I think we should leave it as it is. What we should have is those custom dropdowns.
                        
                            (list :: list)blocks and anything else return a value. Even booleans return values, just true and false. While you can get the value of a list by clicking the above block, it stops making actual sense once you try to implement it for any reason. Because of this nature, throwing a list reporter in
here:
set [ v] to () ::listwould stop making sense very quickly, because that's all you could do with it. Put in any other value and you stop making sense. Set list to 9 makes no sense. While I understand how much sense
set [ v] to [ v] ::listseems to make, well, it would be so much easier if we were allowed to add dropdowns to custom blocks.
Also, when would you really need that? It wouldn't be useful all that often. Besides, you can't have everything done yourself
 I personally think the workaround is really cool. And Scratchers have to learn to work within limits, and not having that block is one of them. As was said in an awesome article I once read, paraphrased because my memory is in no way adamant, “I like limits. Limits force us to come up with new ideas to break boundaries.” So yeah 
 I think we should leave it as it is. What we should have is those custom dropdowns.Last edited by Birdlegs (May 12, 2015 17:08:25)
- DaSpudLord
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
Well, the thing here is thatSo… much… agreeing…(list :: list)blocks and anything else return a value. Even booleans return values, just true and false. While you can get the value of a list by clicking the above block, it stops making actual sense once you try to implement it for any reason. Because of this nature, throwing a list reporter in
here:set [ v] to () ::listwould stop making sense very quickly, because that's all you could do with it. Put in any other value and you stop making sense. Set list to 9 makes no sense. While I understand how much senseset [ v] to [ v] ::listseems to make, well, it would be so much easier if we were allowed to add dropdowns to custom blocks.
Also, when would you really need that? It wouldn't be useful all that often. Besides, you can't have everything done yourselfI personally think the workaround is really cool. And Scratchers have to learn to work within limits, and not having that block is one of them. As was said in an awesome article I once read, paraphrased because my memory is in no way adamant, “I like limits. Limits force us to come up with new ideas to break boundaries.” So yeah
I think we should leave it as it is. What we should have is those custom dropdowns.
- Znapi
 - 
                            
						
						
                            Scratcher
                        
						
						 
500+ posts
Set list block
Also, how would the string be separated into separate items in a list? Or would it only fill a single item in the list? If so, then which item in the list would it fill? The reason we don't have this is because a list is a variable with multiple slots for numbers/strings. Instead, we haveThe idea is based around howreplace item (1 v) of [list v] with []You can't just set a list to a single value because it can have MULTIPLE values.
(list :: list)reports the list represented as one string. This block can take that string and use it to set another list. For example, setting a list to “1 800 HI MOMMY” means the list's contents will be “1”, “800”, “HI”, “MOMMY”. I put together a quick mod in post above if you want to experiment with it and get a feel for how it works.
It takes a string and uses it to set the contents of a list. Each element is separated by spaces, like the current list reporter reports.However, this introduces a problem described earlier in the post.
When a lists has multiple elements that contain spaces words, you can no longer tell where each element starts and stops with the string reported by the current reporter block.
Last edited by Znapi (May 12, 2015 23:04:57)
- Znapi
 - 
                            
						
						
                            Scratcher
                        
						
						 
500+ posts
Set list block
Well, the thing here is thatI had a feeling I wan't clear enough. The reporter block will continue to report a string of all of the elements of the list separated by spaces like it currently does. The format of the string input the simple one the reporter uses, and many Scratchers are familiar with it already. So, setting a list to “9” would mean that the list will contain one element that equals “9”.(list :: list)blocks and anything else return a value. Even booleans return values, just true and false. While you can get the value of a list by clicking the above block, it stops making actual sense once you try to implement it for any reason. Because of this nature, throwing a list reporter in
here:set [ v] to () ::listwould stop making sense very quickly, because that's all you could do with it. Put in any other value and you stop making sense. Set list to 9 makes no sense. While I understand how much senseset [ v] to [ v] ::listseems to make, well, it would be so much easier if we were allowed to add dropdowns to custom blocks.
Also, when would you really need that? It wouldn't be useful all that often. Besides, you can't have everything done yourselfI personally think the workaround is really cool. And Scratchers have to learn to work within limits, and not having that block is one of them. As was said in an awesome article I once read, paraphrased because my memory is in no way adamant, “I like limits. Limits force us to come up with new ideas to break boundaries.” So yeah
I think we should leave it as it is. What we should have is those custom dropdowns.
I agree that the second block is a little useless, partly just an idea I came up with while working on the post. The idea from that came from changing the reporter to report some non-scratchly actionscript data type would not fit with Scratch and an algorithm programmed in Scratch would not be able to modify it. It would end up being like the second block; it set the actionscript contents array of one list directly to the contents array of the other.
- Birdlegs
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
I see where you're coming from and what you mean, but I actually thought the second block was better. The first one really just doesn't make much sense. You could sit and type all of it into one string, but the block would be the same asWell, the thing here is thatI had a feeling I wan't clear enough. The reporter block will continue to report a string of all of the elements of the list separated by spaces like it currently does. The format of the string input the simple one the reporter uses, and many Scratchers are familiar with it already. So, setting a list to “9” would mean that the list will contain one element that equals “9”.(list :: list)blocks and anything else return a value. Even booleans return values, just true and false. While you can get the value of a list by clicking the above block, it stops making actual sense once you try to implement it for any reason. Because of this nature, throwing a list reporter in
here:set [ v] to () ::listwould stop making sense very quickly, because that's all you could do with it. Put in any other value and you stop making sense. Set list to 9 makes no sense. While I understand how much senseset [ v] to [ v] ::listseems to make, well, it would be so much easier if we were allowed to add dropdowns to custom blocks.
Also, when would you really need that? It wouldn't be useful all that often. Besides, you can't have everything done yourselfI personally think the workaround is really cool. And Scratchers have to learn to work within limits, and not having that block is one of them. As was said in an awesome article I once read, paraphrased because my memory is in no way adamant, “I like limits. Limits force us to come up with new ideas to break boundaries.” So yeah
I think we should leave it as it is. What we should have is those custom dropdowns.
I agree that the second block is a little useless, partly just an idea I came up with while working on the post. The idea from that came from changing the reporter to report some non-scratchly actionscript data type would not fit with Scratch and an algorithm programmed in Scratch would not be able to modify it. It would end up being like the second block; it set the actionscript contents array of one list directly to the contents array of the other.
add [] to [ v]
add [] to [ v]
add [] to [ v]
add [] to [ v]
several times. That's why the second block made more sense, but it still just doesn't sound that important or necessary. As I said, you can't have everything done for you.
- Znapi
 - 
                            
						
						
                            Scratcher
                        
						
						 
500+ posts
Set list block
I see where you're coming from and what you mean, but I actually thought the second block was better. The first one really just doesn't make much sense. You could sit and type all of it into one string, but the block would be the same asIt is has uses for slightly more complicated things, where you want to run a list through an algorithm that works better on strings, for making two-dimensional lists, or even passing lists in custom block inputs as strings. The OP discusses some of the uses.add [] to [ v]
add [] to [ v]
add [] to [ v]
add [] to [ v]
several times. That's why the second block made more sense, but it still just doesn't sound that important or necessary. As I said, you can't have everything done for you.
I also changed the OP to not showcase the second, more useless block so much now.
Last edited by Znapi (May 12, 2015 23:16:12)
- Birdlegs
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
Hm… We can make the functions on our own, but you drive a hard point. I do think, though, that a dropdown in custom blocks would mean we could make these ourselves, which would be good. I myself was working a while back on something that would have benefitted from this sort of thing. One master loader had to load lots of different lists, so I had custom blocks stacked on top of each other that checked the right conditions individually and had data loaded into them which was essentially a converted list. Under the properly defined conditions, the block would proceed to fill the master list with the converted list, converting it back, and then the loader would load from the master list. Still, custom blocks take care of all of it for me, so once it's done, I don't have to see its face anymore.I see where you're coming from and what you mean, but I actually thought the second block was better. The first one really just doesn't make much sense. You could sit and type all of it into one string, but the block would be the same asIt is has uses for slightly more complicated things, where you want to run a list through an algorithm that works better on strings, two-dimensional list, or even passing lists in custom block inputs as strings. The OP discusses some of the uses.add [] to [ v]
add [] to [ v]
add [] to [ v]
add [] to [ v]
several times. That's why the second block made more sense, but it still just doesn't sound that important or necessary. As I said, you can't have everything done for you.
I also changed the OP to not showcase the second, more useless block so much now.
- Znapi
 - 
                            
						
						
                            Scratcher
                        
						
						 
500+ posts
Set list block
Hm… We can make the functions on our own, but you drive a hard point. I do think, though, that a dropdown in custom blocks would mean we could make these ourselves, which would be good. I myself was working a while back on something that would have benefitted from this sort of thing. One master loader had to load lots of different lists, so I had custom blocks stacked on top of each other that checked the right conditions individually and had data loaded into them which was essentially a converted list. Under the properly defined conditions, the block would proceed to fill the master list with the converted list, converting it back, and then the loader would load from the master list. Still, custom blocks take care of all of it for me, so once it's done, I don't have to see its face anymore.Sorry for pushing so hard. I guess this is where the “having everything done for you” comes in. I was making lists in lists/two-dimensional lists. I could go and make scripts to load lists, but I was worried about the speed, and other languages have this functionality(for the mod, all I had to do was list.contents = list2.contents. I don't even know actionscript!). I was also trying to see what I need to clarify/get rid of in my post too, because I have a problem with writing concisely. You seem to understand exactly what I mean now, and everyone is entitled to their own opinion on a topic like this. I'll probably end up making custom blocks to do what the block would do, suggested blocks never seem to be added.
- Birdlegs
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Set list block
Woah, that changes things! Firstly, by hard point, I meant you were a good arguer. No apology needed :3 I love a good discussion. But if it's an actual basic, common function, Scratch should have it.Hm… We can make the functions on our own, but you drive a hard point. I do think, though, that a dropdown in custom blocks would mean we could make these ourselves, which would be good. I myself was working a while back on something that would have benefitted from this sort of thing. One master loader had to load lots of different lists, so I had custom blocks stacked on top of each other that checked the right conditions individually and had data loaded into them which was essentially a converted list. Under the properly defined conditions, the block would proceed to fill the master list with the converted list, converting it back, and then the loader would load from the master list. Still, custom blocks take care of all of it for me, so once it's done, I don't have to see its face anymore.Sorry for pushing so hard. I guess this is where the “having everything done for you” comes in. I was making lists in lists/two-dimensional lists. I could go and make scripts to load lists, but I was worried about the speed, and other languages have this functionality(for the mod, all I had to do was list.contents = list2.contents. I don't even know actionscript!). I was also trying to see what I need to clarify/get rid of in my post too, because I have a problem with writing concisely. You seem to understand exactly what I mean now, and everyone is entitled to their own opinion on a topic like this. I'll probably end up making custom blocks to do what the block would do, suggested blocks never seem to be added.
- Discussion Forums
 - » Suggestions
 - 
            » Set list block 
         




