A list is what it sounds like: a number of items placed one after another, as in a shopping list. When you have a list you probably perform one or more associated tasks e.g. collecting the items one by one from around the shop. Other operations might be:
Other examples of lists:
In computer science there are special lists (called data structures) that include: arrays (not in Scratch), linked lists, circular lists, stacks and queues.
Scratch has commands for building and processing lists, which are found under Variables. First you need to make a list and then you will see:
Produce solutions for as many of these as you can:
Think about how many items you want to put in the list. Do you want to use Ask to get the number from the user? Will the items be numbers generated at random? Will they be words entered by the user? Will they be collected from the screen in some way? e.g. by touching a sprite.
For this you can use delete.
For this you would have to look through the list until you find the item required. Will you ask the user to enter the value required?
Insert at the end and the start of a list. Delete from the end and the start. Insert to and delete from any position.
This will require something to hold the count of items.
This will require something to hold the total.
This will require an understanding of what 'shuffle' means. You will have to define this before you write the code. A shuffled list should be in a different order from what it was at the start, as when shuffling a pack of cards.
By now you should be able to solve this yourself.
By now you should be able to solve this yourself.
By now you should be able to solve this yourself.
Use the 'bubble sort'. You will need to understand this before you implement it in Scratch.
Place items in a list at the end and remove them from the same end only. This implements a stack. By now you should be able to solve this yourself.
Insert items at one end of the list and remove them from the other end. This implements a queue. By now you should be able to solve this yourself.
These are basic actions that you could use in a Scratch program such as a game. They are rather abstract in nature and typical of the basic routines found in more advanced programming.
The elevator problem uses a list to store requests for floors. Requests can be placed in the list by the programmer who can either enter values and save the program in that state or use add thing to list to make the program do it at run time. The user can add items to a list by clicking on the display's + sign. Items can also be entered in the request list by clicking on a button that uses add thing to list to insert an item.