Discuss Scratch

24691357
Scratcher
100+ posts

A simple way to add First Class Lists

edward789121test wrote:

-lo- wrote:

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]
And?
24691357
Scratcher
100+ posts

A simple way to add First Class Lists

Sigton wrote:

24691357 wrote:

Sigton wrote:

24691357 wrote:

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
It's pointless.
It sure isn't, I'd use first class lists all the time.
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
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.
edward789121test
New Scratcher
93 posts

A simple way to add First Class Lists

24691357 wrote:

edward789121test wrote:

-lo- wrote:

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]
And?
New scratchers will not understand them.
-Io-
Scratcher
1000+ posts

A simple way to add First Class Lists

edward789121test wrote:

-lo- wrote:

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]
What about it?
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!!!!!
-Io-
Scratcher
1000+ posts

A simple way to add First Class Lists

edward789121test wrote:

Another thing…
THE LIST WATCHERS!!!!!
Snap! does it quite well:
BookOwl
Scratcher
1000+ posts

A simple way to add First Class Lists

BUMP
Jonathan50
Scratcher
1000+ posts

A simple way to add First Class Lists

Bump.

24691357 wrote:

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
BookOwl
Scratcher
1000+ posts

A simple way to add First Class Lists

Bump
BookOwl
Scratcher
1000+ posts

A simple way to add First Class Lists

Bump. I really want this added to Scratch 3!
-stache-
Scratcher
500+ posts

A simple way to add First Class Lists

bump
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

sakafitrady wrote:

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)
Yeah, but it doesn't work like that

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.
duckboycool
Scratcher
1000+ posts

A simple way to add First Class Lists

space_elephant wrote:

I think there should be a different block type for lists.

Support.
That's not what he's suggesting.
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 reporter
[list v] with [thing] inserted to position ( v) ::list reporter
[list v] with item ( v) replaced with [thing] ::list reporter
and they could be put into list dropdowns like
<([list v] with item ( v) replaced with [thing]  ::list reporter) contains [thing] ?>
(item ( v) of ([list v] with item ( v) deleted ::list reporter) :: list)
Also, I wouldn't mind list contains list possibilities, like the list:
  1. ant
  2. bear
  3. cat
  4. dog
  5. eel
  6. fish
  7. goat
containing the list:
  1. cat
  2. dog
  3. eel
, like subsets, but would order matter?
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:
i have variables
(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]
That way first class lists are implemented in the best way!
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"

Powered by DjangoBB