This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-08-30 19:00:06

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Dictionary Lists

Alright, here we go: Dictionary lists!
In programming (for those of you who don't know) dictionaries are lists with "keys" and "values". Each value is obtained by using its key. For example,

Foo: Bar
Hello: World

My dictionary has the value "Bar" at the key "Foo". You can also use numerical keys, like so: (this would help with backwards-compatibility)

1: Foo
2: Bar
3: Baz

Now "Baz" is at "3" and "Foo" at "1". So how would this help? I've come up with a few examples.
1. RPG-like inventories
Users could create inventories with keys being the items and values the quantities, like this: (click to enlarge)
http://i33.tinypic.com/2m2yr28.jpg

2. Lists of unique strings with prices, data, etc.
Users could create lists of unique strings (the keys) with data (such as prices) as the values. For example, here is a small receipt program (in which I spelled receipt wrong):
http://i33.tinypic.com/293ilop.jpg

Note: the reason I have code is because these examples are real, live, working code in a mod.

No more searching/looping through lists to find an item! Just use its key!

New users also wouldn't have to use this functionality as they can use purely numeric keys.

Last edited by nXIII (2010-08-30 21:22:34)


nXIII

Offline

 

#2 2010-08-30 19:09:12

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Dictionary Lists

WHEN IS THE MOD RELEASED?!?
Maybe if Panther becomes stable enough, we can use this for Armour RPG...

Offline

 

#3 2010-08-30 19:10:01

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: Dictionary Lists

Cool, but you could probably just use 2 lists  smile

Last edited by Lucario621 (2010-08-30 19:10:13)


http://i.imgur.com/WBkM2QQ.png

Offline

 

#4 2010-08-30 19:15:56

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Dictionary Lists

Interesting idea! It's really confusing, though - I don't think new users would understand that well.

Besides, what I do right now to achieve the same effect is to use two lists; one for indexing and another for the actual list content. It's not that hard, and it's simple enough for new users to understand.

Offline

 

#5 2010-08-30 19:25:04

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Dictionary Lists

I support!

Maybe I could figure out how to add this to a future version Blocktalk if that's okay with you...  big_smile


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#6 2010-08-30 21:05:16

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Dictionary Lists

GREAT idea. I can see so many uses! Although, I do agree with coolstuff on that.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#7 2010-08-30 21:18:57

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Dictionary Lists

Lucario621 wrote:

Cool, but you could probably just use 2 lists  smile

This is instantly searchable: no more looping through each item of the list!


nXIII

Offline

 

#8 2010-08-30 21:25:30

ihaveamac
Scratcher
Registered: 2007-09-22
Posts: 1000+

Re: Dictionary Lists

http://i35.servimg.com/u/f35/12/25/55/91/thumbs10.jpg


~ihaveamac - visit ihaveamac.net

Offline

 

#9 2010-08-30 22:05:56

Jwosty
Scratcher
Registered: 2009-12-19
Posts: 500+

Re: Dictionary Lists

ihaveamac wrote:

http://i35.servimg.com/u/f35/12/25/55/91/thumbs10.jpg

You just love that picture, don't you?  tongue


http://i39.tinypic.com/18ert5.png Google it.  smile

Offline

 

#10 2010-09-01 20:22:56

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Dictionary Lists

omg you have NO idea how many times I've wanted this.  Actually, this should be pretty easy to implement in my private mod... *starts hacking*

Last edited by rubiks_cube_guy238 (2010-09-01 20:23:18)


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#11 2010-09-01 20:27:57

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Dictionary Lists

Correct me if I'm wrong, but isn't this a list with the ability to have strings as indices?


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#12 2010-09-01 20:44:47

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Dictionary Lists

Harakou wrote:

Correct me if I'm wrong, but isn't this a list with the ability to have strings as indices?

Yep. That's pretty much it!  big_smile


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#13 2010-09-01 20:51:26

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Dictionary Lists

ScratchReallyROCKS wrote:

Harakou wrote:

Correct me if I'm wrong, but isn't this a list with the ability to have strings as indices?

Yep. That's pretty much it!  big_smile

In that case, while I don't see a whole lot of use for this, it could be rather useful and make projects using this sort of system easier. So I give my support.  big_smile


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#14 2010-09-01 20:57:05

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Dictionary Lists

Harakou wrote:

ScratchReallyROCKS wrote:

Harakou wrote:

Correct me if I'm wrong, but isn't this a list with the ability to have strings as indices?

Yep. That's pretty much it!  big_smile

In that case, while I don't see a whole lot of use for this, it could be rather useful and make projects using this sort of system easier. So I give my support.  big_smile

It'd be perfect for cryptography, like saving passwords in an OS. You could have a cell labeled 'a' and it's value would be 'b' so that in a string to be encoded, you could find the value in the dictionary list for each letter.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#15 2010-09-01 22:34:59

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Dictionary Lists

To be honest, I really want 2 dimensional arrays in Scratch, which would be slightly more helpful than this though...

Offline

 

#16 2010-09-02 07:23:43

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Dictionary Lists

shadow_7283 wrote:

To be honest, I really want 2 dimensional arrays in Scratch, which would be slightly more helpful than this though...

Yes, but it is possible to make a list act like a 2-dimensional array.

Anyways, all you have to really do to allow dictionary lists is turn the cellMorphs variable in ScratchListMorphs into a dictionary instead of an orderedcollection.

Last edited by rubiks_cube_guy238 (2010-09-02 07:32:06)


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#17 2010-09-02 07:34:22

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Dictionary Lists

[offtopic]I just noticed, that is a very odd shopping list  lol


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#18 2010-09-02 07:46:43

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Dictionary Lists

This idea looks like it would be right at home in BYOB.

( I hate the)
60 second rule!
60 second rule
60 second rul
60 second ru
60 second r
60 second
60 secon
60 seco
60 sec
60 se
60 s
60
6


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#19 2010-09-02 09:03:05

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Dictionary Lists

Wait, didn't fullmoon implement something like this in BYOB?


Jens Mönig

Offline

 

#20 2010-09-02 10:28:16

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Dictionary Lists

Do you have the changes? Can you post them?


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#21 2010-09-02 12:03:04

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Dictionary Lists

This is awesome! I want to try it!  big_smile


Hai.

Offline

 

#22 2010-09-02 14:44:35

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Dictionary Lists

rubiks_cube_guy238 wrote:

shadow_7283 wrote:

To be honest, I really want 2 dimensional arrays in Scratch, which would be slightly more helpful than this though...

Yes, but it is possible to make a list act like a 2-dimensional array.

Anyways, all you have to really do to allow dictionary lists is turn the cellMorphs variable in ScratchListMorphs into a dictionary instead of an orderedcollection.

Yes, and then add support for that with numberMorphs (have to be completely redone) and all the ops need to be changed and some added, and you need to do a bunch of other thing I forgot...
Oh, yea: you need to make it backwards-compatible. I did this by automatically decrementing numerical indices (above n) when you delete one.


nXIII

Offline

 

#23 2010-09-02 21:05:09

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Dictionary Lists

oh whattheheck, i'm not going to bother doing the hacking. i've tried several times, and its just not working out for me.can you just post the entire class somehow?

Last edited by rubiks_cube_guy238 (2010-09-02 21:05:18)


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#24 2010-09-02 21:08:10

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Dictionary Lists

ScratchReallyROCKS wrote:

[offtopic]I just noticed, that is a very odd shopping list  lol

Uh, 800 computers?


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#25 2010-09-03 08:34:09

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

Re: Dictionary Lists

Harakou wrote:

ScratchReallyROCKS wrote:

[offtopic]I just noticed, that is a very odd shopping list  lol

Uh, 800 computers?

I could really use that.


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

Board footer