Caution.png This article or section is currently undergoing major changes and may be incomplete. Please avoid largely modifying this page's contents until this template has been removed. (October 2023)
Document.png Please expand this article or section. You can help by adding more information if you are an editor. More information might be found in a section of the talk page. (July 2022)

This tutorial explains how to make a two-dimensional list. A two-dimensional list is a list whose contents are also lists. Two-dimensional lists are not a feature included in Scratch, but it can be simulated with two lists.

Preparation

Two lists are necessary to follow the tutorial: one to store the data and another to indicate where each list is in the data.

  • (data::list)
  • (positions::list)

Entering Data

Creating a list

Before you can add data to the lists, you need to create one first by adding an item to the positions list.

add ((length of [data v]) + (1)) to [positions v]

Adding items to the last list

Note Note: This section can only add items to the last list in the list.

To add an item to the end of the last list, you can add the desired item to the end of the data list.

add [item] to [data v]

Inserting items to the last list

Note Note: This section can only insert items to the last list in the list.

To insert an item in the last list, you can add the desired item at a specific position.

insert ( ) at ((item (length of [positions v]) of [positions v]) + (position in list::custom)) of [data v]

Changing an item

You can change data by using the block in the accessing data section to find where the list item is. (x is the position of the list, and y is the position of the list inside x.)

replace item (item (((item (x::custom) of [positions v]) + (y::custom)) - (1)) of [data v]) of [data v] with ( )

Accessing Data

You can access data by checking where the first item in the list is, and then using that to find the location of the item in the specific list. (x is the position of the list, and y is the position of the list inside x.)

(item (((item (x::custom) of [positions v]) + (y::custom)) - (1)) of [data v])

Cookies help us deliver our services. By using our services, you agree to our use of cookies.