Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » New Toy
- davidkayla
-
Scratcher
7 posts
New Toy
Hi,
I understand that I am able to have a list of lists in scratch 2.0:
For example:
toys is a list
children is a list
add (toys) to children
How am I able to set (replace) the third toy for the second child without affecting other toys of the second child?
If I do the following:
replace item (2) of (children) with (toys) then all toys for that child will be written over.
I thought I would be able to do the following:
replace item (2) of (children) with (replace item (3) of (toys) with (new toy))
but it doesn't like that.
Thanks.
I understand that I am able to have a list of lists in scratch 2.0:
For example:
toys is a list
children is a list
add (toys) to children
How am I able to set (replace) the third toy for the second child without affecting other toys of the second child?
If I do the following:
replace item (2) of (children) with (toys) then all toys for that child will be written over.
I thought I would be able to do the following:
replace item (2) of (children) with (replace item (3) of (toys) with (new toy))
but it doesn't like that.
Thanks.
- scimonster
-
Scratcher
1000+ posts
New Toy
You can't have lists of lists in Scratch yet. 
You can try out Snap!, a remix of Scratch that does allow lists of lists (first class lists) and a host of other advanced feature that you don't need to use if you don't want to.

You can try out Snap!, a remix of Scratch that does allow lists of lists (first class lists) and a host of other advanced feature that you don't need to use if you don't want to.
- davidkayla
-
Scratcher
7 posts
New Toy
Hi scimonster,
We may be talking about different things but I have certainly created what I believe is a list of lists in Scratch 2.0 not 1.4.
The following code sets up two lists of toys for two children:
children is list
toys is list
delete (all) of children
delete (all) of toys
add (0) to (toys)
add (0) to (toys)
add (0) to (toys)
add (toys) to (children)
replace item (1) of (toys) with 1
replace item (2) of (toys) with 1
replace item (3) of (toys) with 1
add (toys) to (children)
Please try it. The output of Children certainly looks like a list of lists.
We may be talking about different things but I have certainly created what I believe is a list of lists in Scratch 2.0 not 1.4.
The following code sets up two lists of toys for two children:
children is list
toys is list
delete (all) of children
delete (all) of toys
add (0) to (toys)
add (0) to (toys)
add (0) to (toys)
add (toys) to (children)
replace item (1) of (toys) with 1
replace item (2) of (toys) with 1
replace item (3) of (toys) with 1
add (toys) to (children)
Please try it. The output of Children certainly looks like a list of lists.
- drmcw
-
Scratcher
1000+ posts
New Toy
It's just converting the inner toy list to a string. If it was a list of lists then item x of children would be able to return a list and you could then use item x of item y of children to get the child's individual toys but if you try that you'll find you can't. Sorry!
Last edited by drmcw (July 29, 2013 09:16:18)
- scimonster
-
Scratcher
1000+ posts
New Toy
It's just converting the inner toy list to a string. If it was a list of lists then item x of children would be able to return a list and you could then use item x of item y of children to get the child's individual toys but if you try that you'll find you can't. Sorry!Precisely. What you can do (within the boundaries of Scratch) is use this guide.
- davidkayla
-
Scratcher
7 posts
New Toy
ok, I'll try snap.
If you have any good information about implementing lists of lists in snap please let me know.
Regards,
David.
If you have any good information about implementing lists of lists in snap please let me know.
Regards,
David.
- scimonster
-
Scratcher
1000+ posts
New Toy
ok, I'll try snap.I recommend you post on this topic, and ask Jens or BHarvey for some introductory pointers on first-class data.
If you have any good information about implementing lists of lists in snap please let me know.
Regards,
David.
- Discussion Forums
- » Questions about Scratch
-
» New Toy