In other languages

Help the wiki!

The Scratch Wiki is made by and for Scratchers. Do you want to contribute?

Learn more about joining as an editor!

See discussions in the Community Portal

List

(Redirected from Lists)

An image of a list and example content

A list (called an array in other programming languages) is a tool that can be used to store multiple pieces of information at once. It can also be defined as a variable containing multiple other variables. Although lists are similar to 1 dimensional arrays, meaning that items can not be stored in a theoretical grid, unlike most other programming languages, lists can be made to function like arrays. In fact, though called lists, they are actually resizable arrays for all practical purposes.[1]

A list consists of items, each of which work somewhat like a variable, but with differences.

List blocks can be found in the Data blocks palette.

Contents

List Blocks

Main article: List Blocks
All of the list blocks.
The following blocks can be used to program lists:

Items

An image of an empty list

Items can be added to a list manually or by programming. Items can be deleted in the same manner: manually or by programming. There is no limit to the length of an item or the amount of items a list can hold, apart from an amount sufficient to crash Scratch. However, there are few cases in which a list needs to contain that amount of information.

Example Uses

Some example uses for lists are as follows:

More Complex Uses

  • Storing user-input data in Operating System simulations
  • Storing AI data in games
  • Allowing users to re-create past inputs

Cloud Lists

Main article: Cloud Data

Cloud lists are a coming feature in Scratch 2.0. The values of cloud lists are stored on the Scratch servers; this is the only difference between them and regular lists. When a cloud list gets updated, it does so across all copies of the project. This makes cloud lists ideal for chatroom projects, for example.

It is possible to create a cloud list like this.

Casting

Main article: Casting

Lists are cast to numbers and strings with a set of explicit rules depending on its contents.

Example Projects

Requests

From the time lists were introduced, many users requested two new blocks,hide list [list v] and show list [list v]. Due to such high demand, they were included in Scratch 2.0.

References

  1. http://scratch.mit.edu/forums/viewtopic.php?pid=1258287#p1258287
  • This page was last modified on 12 February 2014, at 01:06.