Discuss Scratch

Monniasza_spzoo
Scratcher
100+ posts

Hash-nested lists

Hybrid of hashtables and nested lists, they are propably most advanced mean of storing information.

Blocks used (exclude red blocks):
Manipulation of individual items of sublists {
add [] to sublist [] of nested list [list v] :: list
delete ( v) from sublist [] of nested list[list v] :: list
insert [] at (1 v) in sublist [] of nested list [list v] :: list
replace item ( v) of sublist [] in nested list [list v] with [thing] :: list
}

Reading of sublists{
reporter (item [] of sublist [] of nested list [list v] :: list)
reporter (length of sublist [] in nested list [list v] :: list)
predicate <sublist [] of nested list [ v] contains [thing] ? :: list>
}

Reading of whole nested list {
predicate <any sublist of nested list[ v] contains [thing] ? :: list>
reporter (sublist count of nested list [list v] :: list)
}

Manipulation of whole sublists {
set sublist [] of nested list [list v] to list [ v] :: list
add list [ v] with name [] of nested list [list v] :: list
delete sublist [] of nested list [list v] :: list
}

Reading whole sublists{
set list [ v] to sublist [] of nested list [list v] :: list
}

Last edited by Monniasza_spzoo (Aug. 21, 2019 12:20:26)

BereketY
Scratcher
500+ posts

Hash-nested lists

Semi-Support.

It seems like a good idea, but wouldn't it be more useful for Scratcher's to make their own encryption/hashes?

Arrays speak to me on a spiritual level.
Monniasza_spzoo
Scratcher
100+ posts

Hash-nested lists

BereketY wrote:

Semi-Support.

It seems like a good idea, but wouldn't it be more useful for Scratcher's to make their own encryption/hashes?
Hash-nested lists don't use hash functions, name is combination of “nested list” and “hashtable”.
DaEpikDude
Scratcher
1000+ posts

Hash-nested lists

I can definitely see these sorts of things being useful, but the blocks look far too confusing for Scratch now.
Maybe hashtables should be added separately (I'd probably go with the name “dictionary” a la Python), then add a feature where you can add lists / dictionaries to lists / dictionaries?

Then you could make it so you can do things like this:
(item (3 v) of (item (2 v) of [2d list v]))
which would give you the 3rd item in the 2nd list in “2d list”. Basically the same as doing "2dlist[1][2]" in any other language.

edit: forgot that square brackets disappear even if it's not valid bbcode in them

Last edited by DaEpikDude (Aug. 27, 2019 00:08:28)


And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
Monniasza_spzoo
Scratcher
100+ posts

Hash-nested lists

DaEpikDude wrote:

I can definitely see these sorts of things being useful, but the blocks look far too confusing for Scratch now.
Maybe hashtables should be added separately (I'd probably go with the name “dictionary” a la Python), then add a feature where you can add lists / dictionaries to lists / dictionaries?

Then you could make it so you can do things like this:
(item (3 v) of (item (2 v) of [2d list v]))
which would give you the 3rd item in the 2nd list in “2d list”. Basically the same as doing "2dlist" in any other language.

Each list is referred to with name. Hash-nested list is hashtable with lists as values and text as keys.
Hash-nested lists are intended for more advanced users.

Last edited by Monniasza_spzoo (Aug. 26, 2019 09:53:31)

DaEpikDude
Scratcher
1000+ posts

Hash-nested lists

Monniasza_spzoo wrote:

-snip-
Each list is referred to with name. Hash-nested list is hashtable with lists as values and text as keys.
Hash-nested lists are intended for more advanced users.
I get what a hashtable is, I'm saying that they should be added separately and then you should be able to put lists in lists or hashtables in lists or whatever you want anyway without needing new blocks.
So you could do something like:
(item [foo] of dictionary (item [bar] of dictionary [nested dictionary v]::list)::list)
for nested hashtables / dictionaries.

If this sort of “general” nesting was supported, then we'd need less blocks in the palette, just the new blocks for dictionaries (instead of adding another 13 blocks specifically for nested hashtables on top of another 9 for non-listed hashtables, you'd just need the new 9) and it'd also be more flexible with what you could do with it (you could have like 10 nested lists, or a list in a hashtable in a list or whatever).

The only problem with this idea I can think of is how would the list display work? Maybe the nested lists would be indented slightly and have a different numbering system (like 1.1, 1.2, 1.3 and so on)?
…I should probably just make a separate suggestion for this, shouldn't I?

And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
awesome5185
Scratcher
1000+ posts

Hash-nested lists

Monniasza_spzoo wrote:

DaEpikDude wrote:

I can definitely see these sorts of things being useful, but the blocks look far too confusing for Scratch now.
Maybe hashtables should be added separately (I'd probably go with the name “dictionary” a la Python), then add a feature where you can add lists / dictionaries to lists / dictionaries?

Then you could make it so you can do things like this:
(item (3 v) of (item (2 v) of [2d list v]))
which would give you the 3rd item in the 2nd list in “2d list”. Basically the same as doing "2dlist" in any other language.

Each list is referred to with name. Hash-nested list is hashtable with lists as values and text as keys.
Hash-nested lists are intended for more advanced users.
Everything else aside, Scratch is meant to be user friendly and having hashes might unnecessarily confuse such people. Advanced users would most likely already have moved on to other languages.

Regards,
awesome5185

Featured Studio!
Ask Ouija!
Ask a question and get your answers one. letter. at. a. time. Join now!

; Santa Claus and Mrs Claus wanted to get a devorce. However, being in the north pole, there was no one there to help them do that. So they used a semi colon instead; they are great for seperating two independent clauses.
DaEpikDude
Scratcher
1000+ posts

Hash-nested lists

awesome5185 wrote:

-snip-
Everything else aside, Scratch is meant to be user friendly and having hashes might unnecessarily confuse such people. Advanced users would most likely already have moved on to other languages.
Hashtables / dictionaries aren't really that complicated, they're basically just lists that have a name for each element instead of a number.

Although I think this thread kinda shows that they should have a name other than hashtables, because apparently that name gets them confused with hashes which aren't the same thing at all

And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
Monniasza_spzoo
Scratcher
100+ posts

Hash-nested lists

DaEpikDude wrote:

awesome5185 wrote:

-snip-
Everything else aside, Scratch is meant to be user friendly and having hashes might unnecessarily confuse such people. Advanced users would most likely already have moved on to other languages.
Hashtables / dictionaries aren't really that complicated, they're basically just lists that have a name for each element instead of a number.

Although I think this thread kinda shows that they should have a name other than hashtables, because apparently that name gets them confused with hashes which aren't the same thing at all
Hash-nested list is collection of lists, each with its own name.
WindOctahedron
Scratcher
1000+ posts

Hash-nested lists

Again, your suggestion has been rejected:

Za-Chary wrote:

1.7 2D lists
2D lists, also known as 2D arrays, nested lists, or matrices, are a type of data structure that allows you to put an entire list as an element of another list; that is, it allows you to put lists inside of lists. These sorts of data structures are used widely in other programming languages.

The block below, and others, would allow you to create 2D lists to store information, sort of like a table. However, this is too complicated for what is supposed to be an introductory programming language. In addition, there are workarounds possible by using an ordinary list and an indexing function.

For those who are interested, it may be worth checking out Snap. It is a block-based programming language designed for more experienced programmers, and has more advanced data structures than Scratch does.

add () to sublist () of [list v] :: list

The message above may contain wrong information, rude remarks, or something embarrassing to my current self. In this case, please ignore it and remember that I likely wrote it back when I didn't know what “respect” truly meant. I really hate thinking about it again.
Za-Chary
Scratcher
1000+ posts

Hash-nested lists

Closed as rejected, as it uses nested lists.

This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.

I was a Scratch Team member from May 10th 2019 to October 29th 2021.

my notebook | scratch team essay | accessibility essay

Powered by DjangoBB