Discuss Scratch

TheGuyWithTheHat2
Scratcher
33 posts

Block Idea: Place of [word] in [list]

(place of [thing] in [list v]::list)
I don't know why this block doesn't exist yet. It's MUCH easier than making a bunch of blocks to scan through a list.

“Oh what if there isn't any of it in the list”
Two solutions.
if <[vegetables v] contains [apple ]> then
do whatever to (place of [apple] in [vegetables v]::list)
end
or
< (place of [apple] in [vegetables v]::list) = [0]>

I'm not a programming language programmer so I don't know if you can or can't do this, but I think you'd have a block like this by now.
THE END

Last edited by TheGuyWithTheHat2 (Dec. 9, 2014 21:48:14)

Zro716
Scratcher
1000+ posts

Block Idea: Place of [word] in [list]

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] to (place of [thing] in [list v] ::list)
now what
djdolphin
Scratcher
1000+ posts

Block Idea: Place of [word] in [list]

Zro716 wrote:

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] to (place of [thing] in [list v] ::list)
now what
Average them - 2.5

jk
ChocolatePi
Scratcher
1000+ posts

Block Idea: Place of [word] in [list]

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] ((1st v) occurrence of [thing] in [list v] :: list) :: variables
set [index v] ((last v) occurrence of [thing] in [list v] :: list) :: variables

I've actually wanted this

Last edited by ChocolatePi (Dec. 9, 2014 22:52:24)

stickfiregames
Scratcher
1000+ posts

Block Idea: Place of [word] in [list]

Support, it would be useful for indexing lists.
TheGuyWithTheHat2
Scratcher
33 posts

Block Idea: Place of [word] in [list]

Zro716 wrote:

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] to (place of [thing] in [list v] ::list)
now what

Hmmmmm
I guess the first one, unless you use the block ChocolatePi made
What other problems could that come across? I know you guys love finding those in your free time
Cyoce
Scratcher
500+ posts

Block Idea: Place of [word] in [list]

Support. This would make creating “project cookies” (data that is specific to a user for that project, e.g. highscores) much easier.

Last edited by Cyoce (Dec. 10, 2014 00:19:24)

MegaApuTurkUltra
Scratcher
1000+ posts

Block Idea: Place of [word] in [list]

Zro716 wrote:

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] to (place of [thing] in [list v] ::list)
now what
It would return the first index where it was found. I mean, that's how things like JavaScript arrays work.

Support for this
Cyoce
Scratcher
500+ posts

Block Idea: Place of [word] in [list]

MegaApuTurkUltra wrote:

Zro716 wrote:

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] to (place of [thing] in [list v] ::list)
now what
It would return the first index where it was found. I mean, that's how things like JavaScript arrays work.

Support for this
So how about
(first occurence of  [thing] in [list v] :: list)
To avoid confusing people?

Last edited by Cyoce (Dec. 10, 2014 23:13:59)

ChocolatePi
Scratcher
1000+ posts

Block Idea: Place of [word] in [list]

Cyoce wrote:

MegaApuTurkUltra wrote:

Zro716 wrote:

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] to (place of [thing] in [list v] ::list)
now what
It would return the first index where it was found. I mean, that's how things like JavaScript arrays work.

Support for this
So how about
first occurence of  [thing] in [list v] :: list
To avoid confusing people?
what about mine?

ChocolatePi wrote:

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] ((1st v) occurrence of [thing] in [list v] :: list) :: variables
set [index v] ((last v) occurrence of [thing] in [list v] :: list) :: variables

I've actually wanted this
Cyoce
Scratcher
500+ posts

Block Idea: Place of [word] in [list]

ChocolatePi wrote:

Cyoce wrote:

MegaApuTurkUltra wrote:

Zro716 wrote:

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] to (place of [thing] in [list v] ::list)
now what
It would return the first index where it was found. I mean, that's how things like JavaScript arrays work.

Support for this
So how about
(first occurence of  [thing] in [list v] :: list)
To avoid confusing people?
what about mine?

ChocolatePi wrote:

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] ((1st v) occurrence of [thing] in [list v] :: list) :: variables
set [index v] ((last v) occurrence of [thing] in [list v] :: list) :: variables

I've actually wanted this
I like yours better, but my suggestion was just to clarify the block he was creating.
I would prefer yours, but if the block were to simply return the first one, it should be named as such.
Alberknyis
Scratcher
1000+ posts

Block Idea: Place of [word] in [list]

Zro716 wrote:

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] to (place of [thing] in [list v] ::list)
now what

1.

Or zero if you do python/other languages that I don't know about
theonlygusti
Scratcher
1000+ posts

Block Idea: Place of [word] in [list]

Alberknyis wrote:

Zro716 wrote:

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] to (place of [thing] in [list v] ::list)
now what

1.

Or zero if you do python/other languages that I don't know about
You meant bad languages.
Zappy1333
Scratcher
100+ posts

Block Idea: Place of [word] in [list]

Support!
SuperDragon2014
Scratcher
45 posts

Block Idea: Place of [word] in [list]

Support
Prinseskat
Scratcher
1000+ posts

Block Idea: Place of [word] in [list]

ChocolatePi wrote:

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] ((1st v) occurrence of [thing] in [list v] :: list) :: variables
set [index v] ((last v) occurrence of [thing] in [list v] :: list) :: variables

I've actually wanted this
Support this!
Alberknyis
Scratcher
1000+ posts

Block Idea: Place of [word] in [list]

theonlygusti wrote:

Alberknyis wrote:

Zro716 wrote:

add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
add [thing] to [list v]
set [index v] to (place of [thing] in [list v] ::list)
now what

1.

Or zero if you do python/other languages that I don't know about
You meant bad languages.

No, I meant other languages.
rollercoasterfan
Scratcher
1000+ posts

Block Idea: Place of [word] in [list]

Support for
((1st v) occurence of [thing] in [list v] ::list)
((last v) occurence of [thing] in [list v] ::list)
EncloCreations
Scratcher
500+ posts

Block Idea: Place of [word] in [list]

Support
monstermash3
Scratcher
1000+ posts

Block Idea: Place of [word] in [list]

Support! In fact, I've been REALLY wishing there was a
delete all occurrences of [thing] in [list v]::list
for a while.
But I agree with rollercoasterfan's idea:

rollercoasterfan wrote:

Support for
((1st v) occurence of [thing] in [list v] ::list)
((last v) occurence of [thing] in [list v] ::list)
since it wouldn't work if there was more than one occurence.
This is workaroundable, however.
(occurence (2 v) of [thing] in [list v] ::list)
would be workaroundable as follows.
For example,
say (join [The second occurrence of the string "thing" in the list is item ] (join (occurrence (2 v) of [thing] in [list v]::list) [.])
would be
set [item v] to [1]
set [occurrences v] to [0]
repeat until <(occurrences) = [2]>
if <(item (item) of [list v]) = [thing]> then
change [occurrences v] by [1]
end
change [item v] by [1]
end
say (join [The second occurrence of the string "thing" in the list is item ] (join ((item) - (1)) [.])
But that workaround is not that easy, so I still support.

Last edited by monstermash3 (July 27, 2015 00:23:35)

Powered by DjangoBB