Discuss Scratch
- Discussion Forums
- » Suggestions
- » A simple way to add First Class Lists
- 24691357
-
Scratcher
100+ posts
A simple way to add First Class Lists
And?If you put a list reporter in a input, it's much more natural to return the list itself and not a text representation.but…add [] to [=]
delete ( v) of [=]
insert [] at (1 v) of [=]
replace item ( v) of [=] with [thing]
- 24691357
-
Scratcher
100+ posts
A simple way to add First Class Lists
Adding block “empty list” is like not having negative numbers implemented, then adding block “-1” for this. You can't modify the empty list, and you can't modify -1.It sure isn't, I'd use first class lists all the time.It's pointless.Make a list called “empty list” and don't add anything to it.We're not referencing an existing list here, that's the point of the block.
It creates an instance of an empty list inside a variable.
Sigton
Depending on the level of the user the complexity would change. A new scratcher might not even use it at all. Experienced scratchers can use it to create complex data structures before extremely complicated to replicate.
Sigton
- edward789121test
-
New Scratcher
93 posts
A simple way to add First Class Lists
New scratchers will not understand them.And?If you put a list reporter in a input, it's much more natural to return the list itself and not a text representation.but…add [] to [=]
delete ( v) of [=]
insert [] at (1 v) of [=]
replace item ( v) of [=] with [thing]
- -Io-
-
Scratcher
1000+ posts
A simple way to add First Class Lists
What about it?If you put a list reporter in a input, it's much more natural to return the list itself and not a text representation.but…add [] to [=]
delete ( v) of [=]
insert [] at (1 v) of [=]
replace item ( v) of [=] with [thing]
You just put the variable in.
add [] to (list)
- edward789121test
-
New Scratcher
93 posts
A simple way to add First Class Lists
Another thing…
THE LIST WATCHERS!!!!!
THE LIST WATCHERS!!!!!
- -Io-
-
Scratcher
1000+ posts
A simple way to add First Class Lists
Another thing…Snap! does it quite well:
THE LIST WATCHERS!!!!!

- Jonathan50
-
Scratcher
1000+ posts
A simple way to add First Class Lists
Bump.
Adding block “empty list” is like not having negative numbers implemented, then adding block “-1” for this. You can't modify the empty list,Why do you think that? OP isn't suggesting adding a block that returns the empty list, but one that returns a newly allocated empty list.
and you can't modify -1.You don't need to:
((-1 :: operators) * (3)) //-3…but that's annoying. Just having an “empty list” block isn't as annoying as that though.
Last edited by Jonathan50 (Aug. 29, 2016 07:41:10)
- Jonathan50
-
Scratcher
1000+ posts
A simple way to add First Class Lists
How about
(make an empty list :: list)?
- BookOwl
-
Scratcher
1000+ posts
A simple way to add First Class Lists
Bump. I really want this added to Scratch 3!
- sakafitrady
-
Scratcher
100+ posts
A simple way to add First Class Lists
If I understand correctly, lists in lists?
Insert list [Row 1 v] into [Board v] :: list
insert (Row 1:: list) at (1 v) of [Board v]and when you want to access an item:
Item (1 v) of sub-list (Row 1 :: list) in (Board v) :: list
(item (1 v) of (item (1 v) of [Board v] :: list) :: list)
- Sigton
-
Scratcher
1000+ posts
A simple way to add First Class Lists
If I understand correctly, lists in lists?Yeah, but it doesn't work like thatInsert list [Row 1 v] into [Board v] :: listinsert (Row 1:: list) at (1 v) of [Board v]and when you want to access an item:Item (1 v) of sub-list (Row 1 :: list) in (Board v) :: list(item (1 v) of (item (1 v) of [Board v] :: list) :: list)

Sigton
- space_elephant
-
Scratcher
500+ posts
A simple way to add First Class Lists
I think there should be a different block type for lists.
Support.
Support.
- duckboycool
-
Scratcher
1000+ posts
A simple way to add First Class Lists
I think there should be a different block type for lists.That's not what he's suggesting.
Support.
- IcyCoder
-
Scratcher
1000+ posts
A simple way to add First Class Lists
Whoa no clue what happened (ignore)
Last edited by IcyCoder (Feb. 14, 2017 01:16:33)
- dvargasews
-
Scratcher
500+ posts
A simple way to add First Class Lists
How about if these were added?
[list v] with item ( v) deleted ::list reporterand they could be put into list dropdowns like
[list v] with [thing] inserted to position ( v) ::list reporter
[list v] with item ( v) replaced with [thing] ::list reporter
<([list v] with item ( v) replaced with [thing] ::list reporter) contains [thing] ?>Also, I wouldn't mind list contains list possibilities, like the list:
(item ( v) of ([list v] with item ( v) deleted ::list reporter) :: list)
- ant
- bear
- cat
- dog
- eel
- fish
- goat
- cat
- dog
- eel
- kenny2scratch
-
Scratcher
500+ posts
A simple way to add First Class Lists
I see what you're doing here. Did you perhaps get the idea for this from Blockly? I seem to remember a similar way of doing first class lists.
A little suggestion: make the second input in that block a variable selection but make the variable selection accept variables:
Some block mock-ups:
A little suggestion: make the second input in that block a variable selection but make the variable selection accept variables:
i have variablesThat way first class lists are implemented in the best way!
(var1 :: variables)
(var2 :: variables)
(var3 :: variables)
so i can add x to
add (x) to [var1 v]
add (x) to [var2 v]
add (x) to [var3 v]
Some block mock-ups:
set [a v] to (empty list :: list) // INITIALIZE LIST
set [b v] to (empty list :: list)
set [c v] to (empty list :: list)
add [asdf] to [b v]
add [sdaf] to [b v]
add [fdsa] to [c v]
add [dsfa] to [c v]
add (b :: variables) to [a v]
add (c :: variables) to [a v]
(item (1 v) of (item (1 v) of [a v] :: list) :: list) // reports "asdf"
(item (1 v) of (item (2 v) of [a v] :: list) :: list) // reports "fdsa"
(item (2 v) of (item (1 v) of [a v] :: list) :: list) // reports "sdaf"
(item (2 v) of (item (2 v) of [a v] :: list) :: list) // reports "dsfa"
- Discussion Forums
- » Suggestions
-
» A simple way to add First Class Lists












