Discuss Scratch

theonlygusti
Scratcher
1000+ posts

New block

With the addition of just one, simple block, Scratch would become so much more powerful:

New Block
(list [] ◀ ▶ :: list)

This block creates and reports lists,



This block would enable lists to become first class data-types.

A first class data-type can be:
  • the value of a variable
  • an input to a procedure/function
  • the return value of a procedure/function
  • anonymous (not named)

So, lists would become much more powerful: you could create 2-dimensional, 3, 4, 5-dimensional arrays easily

and much more.

————————————————————————————————————————


TL;DR

Basically, this block allows you to create a list.

Previously, in Scratch you'd have to create a list (using the “Make a List” button), name it and then run something like:

add [first] to [list v]
add [second] to [list v]
add [third] to [list v]

But with this block you can create exactly the same list without having to name it, add items to it, etc.

(list [first] [second] [third] ◀ ▶ :: list) // first, second, third

They both produce the same list!

————————————————————————————————————————


Usage

Because they are first-class data structures now, they can be assigned to variables:

set [triangle v] to (list (list [-30] [0] ◀ ▶ :: list) (list [30] [0] ◀ ▶ :: list) (list [0] [51.96] ◀ ▶ :: list) ◀ ▶ :: list)
go to x: (item (1 v) of (item (1 v) of (triangle))) y: (item (2 v) of (item (1 v) of (triangle)))
pen down
go to x: (item (1 v) of (item (2 v) of (triangle))) y: (item (2 v) of (item (2 v) of (triangle)))
go to x: (item (1 v) of (item (3 v) of (triangle))) y: (item (2 v) of (item (3 v) of (triangle)))
go to x: (item (1 v) of (item (1 v) of (triangle))) y: (item (2 v) of (item (1 v) of (triangle)))
pen up

The above code would draw an (almost) equilateral triangle between the vertices (-30, 0), (30, 0) and (0, 51.96). These vertices were able to be stored as (x, y) lists within a variable.

You would also be able to pass the lists as arguments to a function:

define tell story (lines)
set [current line v] to (1)
repeat (length of (lines) :: list)
say (item (current line) of (lines)) for [2] secs
change [current line v] by (1)
end

tell story (list [I am HAB, your Help & Advice Bot!] [You have to find the button to get out,] [move with the WASD keys. Try it now!] ◀ ▶ :: list)

The above code would give short lines of a longer monologue is a sequential order.

Now, don't bash these examples directly, as they were chosen simply to demonstrate how this block is used, not its actual uses. The uses of this block would extend far beyond simply telling stories.

Last edited by theonlygusti (May 5, 2016 15:47:36)

theonlygusti
Scratcher
1000+ posts

New block

Bump?
theonlygusti
Scratcher
1000+ posts

New block

Also, it will allow for possible future blocks like python's for loop:
foreach ((c) :: control) in (range (0) to (10) :: custom) :: control cstart
say (c) for (0.5) secs
end
theonlygusti
Scratcher
1000+ posts

New block

Bump.
comp09
Scratcher
1000+ posts

New block

This is an excellent idea. I support.

Also, BUMPITY BUMP!
Scratchifier
Scratcher
1000+ posts

New block

I don't quite understand this block. Perhaps you could add a more detailed explanation for people who haven't taken another programming language outside of Scratch?

Like, I'm learning C#, but I'm not there yet, so I don't really know what you're suggesting.
comp09
Scratcher
1000+ posts

New block

Scratchifier wrote:

I don't quite understand this block. Perhaps you could add a more detailed explanation for people who haven't taken another programming language outside of Scratch?

Like, I'm learning C#, but I'm not there yet, so I don't really know what you're suggesting.
This block would make lists first class data types, like Snap!

That means we can have lists inside lists inside lists…
theonlygusti
Scratcher
1000+ posts

New block

comp09 wrote:

Scratchifier wrote:

I don't quite understand this block. Perhaps you could add a more detailed explanation for people who haven't taken another programming language outside of Scratch?

Like, I'm learning C#, but I'm not there yet, so I don't really know what you're suggesting.
This block would make lists first class data types, like Snap!

That means we can have lists inside lists inside lists…
Inside variables inside procedures inside lists…
MegaApuTurkUltra
Scratcher
1000+ posts

New block

OVER 9000 (technically 8000) support for this!
Tropic
Scratcher
1000+ posts

New block

Actually, I made a custom block (containing some hacked blocks) that can create a list, but it can't create multidimensional lists so this might still be useful
Prinseskat
Scratcher
1000+ posts

New block

Support!
CatsUnited
Scratcher
1000+ posts

New block

I find it really confusing, especially that this is already in Snap and I have no idea how to use it.
theonlygusti
Scratcher
1000+ posts

New block

CatsUnited wrote:

I find it really confusing, especially that this is already in Snap and I have no idea how to use it.
Really? In snap you use it like:

map ((() x (10) :: operators) :: grey ring) over (list [1] [2] :: list) :: list reporter

It just replaces regular lists.
Iditaroid
Scratcher
500+ posts

New block

I love what this block adds but at the same time it was confusing to figure out at first when i saw it in Snap and i don't think it would be a great addition to Scratch!
Deerleg
Scratcher
1000+ posts

New block

No support.

For one, beginners would not understand the purpose of this block.

And couldn't you just do this with a couple lists?
1. Empty three pre-made lists
2. Put stuff in them with the “add stuff” block
3. Go through each list with a loop of some sort and add each thing in the lists to another list
4. Done!

And
add (stuff) to [ list v]
Not sure how it would work with functions but it should be possible.
CatsUnited
Scratcher
1000+ posts

New block

theonlygusti wrote:

CatsUnited wrote:

I find it really confusing, especially that this is already in Snap and I have no idea how to use it.
Really? In snap you use it like:

map ((() x (10) :: operators) :: grey ring) over (list [1] [2] :: list) :: list reporter

It just replaces regular lists.
Okay, but make sure you can still create scratch lists! Support.
theonlygusti
Scratcher
1000+ posts

New block

Deerleg wrote:

No support.

For one, beginners would not understand the purpose of this block.

And couldn't you just do this with a couple lists?
1. Empty three pre-made lists
2. Put stuff in them with the “add stuff” block
3. Go through each list with a loop of some sort and add each thing in the lists to another list
4. Done!

And
add (stuff) to [ list v]
Not sure how it would work with functions but it should be possible.
No.

The point of this is to have first-class lists, not more lists than needed.

Your suggested method doesn't create multidimensional lists, just four named lists, three of which are redundant, and one of which is pointless.

CatsUnited
Scratcher
1000+ posts

New block

theonlygusti wrote:

Deerleg wrote:

No support.

For one, beginners would not understand the purpose of this block.

And couldn't you just do this with a couple lists?
1. Empty three pre-made lists
2. Put stuff in them with the “add stuff” block
3. Go through each list with a loop of some sort and add each thing in the lists to another list
4. Done!

And
add (stuff) to [ list v]
Not sure how it would work with functions but it should be possible.
No.

The point of this is to have first-class lists, not more lists than needed.

Your suggested method doesn't create multidimensional lists, just four named lists, three of which are redundant, and one of which is pointless.

I think that making lists first class may be too expensive for new scratchers, so we end up staying in business or economy class .
Anyway, I still support, let's have some of the most luxurious seats on the plane!
Deerleg
Scratcher
1000+ posts

New block

theonlygusti wrote:

Deerleg wrote:

No support.

For one, beginners would not understand the purpose of this block.

And couldn't you just do this with a couple lists?
1. Empty three pre-made lists
2. Put stuff in them with the “add stuff” block
3. Go through each list with a loop of some sort and add each thing in the lists to another list
4. Done!

And
add (stuff) to [ list v]
Not sure how it would work with functions but it should be possible.
No.

The point of this is to have first-class lists, not more lists than needed.

Your suggested method doesn't create multidimensional lists, just four named lists, three of which are redundant, and one of which is pointless.

Well, at least my first point is right.
No support anyway.
Rex208
Scratcher
500+ posts

New block

Support!

Powered by DjangoBB