Discuss Scratch

HAL95131
Scratcher
500+ posts

"pseudo" first class lists

HAL95131 wrote:

well, that returns a string and doesn't let you make a new one inline
psst, as a side note, this would probably work better if list reporters returned actual lists instead of strings! but shhhh, that's not the suggestion

so to support the block i'm about to suggest, all list blocks would have circle dropdowns instead of square dropdowns (which do nothing if the list you put into them is invalid)

and now to the main suggestion !

(list out (...) by each [,] :: list)

essentially what this block does is return a list just like a normal list (array) in scratch.
why don't we just use a normal list as a temporary one? well, that returns a string and doesn't let you make a new one inline

to expand or replace items in this list, we can attach it to a variable (that gets appended an icon, this is purely visual to show the type. it does not change the variable's name) and run normal list blocks on it

and then when we want to use it, we can just put it into a “finished list” list like this:

define set new list (data) (list name)
delete all of (list name)
set [i v] to [1]
repeat (length of (data) :: list)
add (item (i) of (data)) to (list name)

and of course, maybe we'd want to check if data and list names are lists in the first place… but that's better as a separate suggestion

Last edited by HAL95131 (Oct. 2, 2026 15:38:26)

Haycat2009
Scratcher
500+ posts

"pseudo" first class lists

Support. What I like is how this makes 2d lists trivial to make.

Powered by DjangoBB