Discuss Scratch

CGRises
Scratcher
500+ posts

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

([First v] occurrence of [item] in [list v]::list)
set [place v] to [0]
set [counter v] to [1]
repeat until <<not <(place) = [0]>> or <(counter) = (length of [list v])>>
if <(item (counter) of [list v]) = (item)> then
set [place v] to (counter)
end
change [counter v] by (1)
end



([last v] occurrence of [item] in [list v]::list)
set [place v] to [0]
set [counter v] to [1]
repeat until <(counter) = (length of [list v])>

if <(item (counter) of [list v]) = (item)> then
set [place v] to (counter)
end
change [counter v] by (1)
end
([average v] occurrence of [item] in [list v]::list)
delete (all v) of [list of places v]
set [place v] to [0]
set [counter v] to [1]
repeat until <(counter) = (length of [list v])>

if <(item (counter) of [list v]) = (item)> then
add [place v] to [list of places v]
end
change [counter v] by (1)
end
set [counter v] to [1]
set [sum v] to [0]
repeat (length of [list of places v])
set [sum v] to ((item (counter) of [list of places v]) + (sum))
change [counter v] by (1)
end
set [place v] to ((sum) / (length of [list of places v]))

((number) occurrence of [item] in [list v]::list)
delete (all v) of [list of places v]
set [place v] to [0]
set [counter v] to [1]
repeat until <(counter) = (length of [list v])>
if <(item (counter) of [list v]) = (item)> then
add (counter) to [list of places v]
end
change [counter v] by (1)
end
set [place v] to (item (number) of [list of places v])
In all cases above, the “place” variable, is the answer.
No support.

Last edited by CGRises (July 27, 2015 14:06:29)

monstermash3
Scratcher
1000+ posts

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

CGRises wrote:

...
In all cases above, the “place” variable, is the answer.
No support.
It's not a very easy workaround though.
CGRises
Scratcher
500+ posts

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

monstermash3 wrote:

CGRises wrote:

...
In all cases above, the “place” variable, is the answer.
No support.
It's not a very easy workaround though.
I think it is. Anyways, you wanted a delete all occurrences?


Delete all occurrences of [thing] in [list v]::list


delete (all v) of [occurrences v]
set [counter v] to [1]
repeat (length of [list v])

if <(item (counter) of [list v]) = [thing]> then

add (counter) to [occurrences v]
end
change [counter v] by (1)
end
set [counter v] to (length of [occurrences v])
repeat (length of [occurrences v])
delete (item (item (counter) of [occurrences v]) of [list v]) of [list v]
change [counter v] by (-1)
end

Last edited by CGRises (July 27, 2015 00:38:40)

iamunknown2
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.
Give me a text-based programming language that doesn't have an array-index system which starts at 0.
monstermash3
Scratcher
1000+ posts

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

CGRises wrote:

monstermash3 wrote:

CGRises wrote:

...
In all cases above, the “place” variable, is the answer.
No support.
It's not a very easy workaround though.
I think it is. Anyways, you wanted a delete all occurrences?


Delete all occurrences of [thing] in [list v]::list

...
Couldn't you just do this?
set [item v] to [1]
repeat (length of [list v])
if <(item (item) of [list v]) = [thing]> then
delete (item) of [list v]
end
change [item v] by [1]
end
Still, it's not too easy.


iamunknown2
Scratcher
1000+ posts

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

monstermash3 wrote:

CGRises wrote:

monstermash3 wrote:

CGRises wrote:

...
In all cases above, the “place” variable, is the answer.
No support.
It's not a very easy workaround though.
I think it is. Anyways, you wanted a delete all occurrences?


Delete all occurrences of [thing] in [list v]::list

...
Couldn't you just do this?
set [item v] to [1]
repeat (length of [list v])
if <(item (item) of [list v]) = [thing]> then
delete (item) of [list v]
end
change [item v] by [1]
end
Still, it's not too easy.


You can't. The list of items would shift whenever you deleted an item.

Plus, the workaround isn't difficult, and I would doubt that New Scratchers would even use lists.
Cream_E_Cookie
Scratcher
1000+ posts

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

rollercoasterfan wrote:

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

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

Support, because this is a very logical, stanndard part of lists
CGRises
Scratcher
500+ posts

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

iamunknown2 wrote:

monstermash3 wrote:

CGRises wrote:

monstermash3 wrote:

CGRises wrote:

...
In all cases above, the “place” variable, is the answer.
No support.
It's not a very easy workaround though.
I think it is. Anyways, you wanted a delete all occurrences?


Delete all occurrences of [thing] in [list v]::list

...
Couldn't you just do this?
set [item v] to [1]
repeat (length of [list v])
if <(item (item) of [list v]) = [thing]> then
delete (item) of [list v]
end
change [item v] by [1]
end
Still, it's not too easy.


You can't. The list of items would shift whenever you deleted an item.

Plus, the workaround isn't difficult, and I would doubt that New Scratchers would even use lists.
thank you.
Deerleg
Scratcher
1000+ posts

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

SUPPORT!

As to the workaround, I really do not want to have such a long block of code just to do that.
IronBit_Studios
Scratcher
1000+ posts

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

Support to ChocolatePi.

Deerleg wrote:

As to the workaround, I really do not want to have such a long block of code just to do that.
TheGuyWithTheHat2
Scratcher
33 posts

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

The workaround would also seriously slow down things for complicated scripts I think

Last edited by TheGuyWithTheHat2 (July 27, 2015 15:18:42)

monstermash3
Scratcher
1000+ posts

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

iamunknown2 wrote:

You can't. The list of items would shift whenever you deleted an item.
Oh, right. Fixed workaround:
set [item v] to [1]
repeat until <(item) > ((length of [list v]) - (1))>
if <(item (item) of [list v]) = [thing]> then
delete (item) of [list v]
else
change [item v] by (1)
end
end
But I still support. See the above post.

CGRises
Scratcher
500+ posts

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

Okay guys, look.
Not everything on scratch is easy. You are asking for a tailor made block when you can do the patchwork of the workaround yourself.
I don't think the workaround is hard for intermediate and above. New Scratchers wouldn't use it anyways. Scratch is made with a low floor, and a high ceiling. Because of the workaround, this block will only raise the floor.
There are no uses for the block I can think of of the top of my head, (except the delete all occurrences).
Scratch is made with a low floor, and a high ceiling. Because of the workaround, this block will only raise the floor.
I've already stated it before: No support.

Last edited by CGRises (July 28, 2015 13:51:33)

Cream_E_Cookie
Scratcher
1000+ posts

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

CGRises wrote:

Okay guys, look.
Not everything on scratch is easy. You are asking for a tailor made block when you can do the patchwork of the workaround yourself.
I don't think the workaround is hard for intermediate and above. New Scratchers wouldn't use it anyways. Scratch is made with a low floor, and a high ceiling. Because of the workaround, this block will only raise the floor.
There are no uses for the block I can think of of the top of my head, (except the delete all occurrences).
Scratch is made with a low floor, and a high ceiling. Because of the workaround, this block will only raise the floor.
I've already stated it before: No support.
Um, these blocks have just the same difficulty level workarounds:
move () steps

go to [ v]
CGRises
Scratcher
500+ posts

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

Cream_E_Cookie wrote:

CGRises wrote:

Okay guys, look.
Not everything on scratch is easy. You are asking for a tailor made block when you can do the patchwork of the workaround yourself.
I don't think the workaround is hard for intermediate and above. New Scratchers wouldn't use it anyways. Scratch is made with a low floor, and a high ceiling. Because of the workaround, this block will only raise the floor.
There are no uses for the block I can think of of the top of my head, (except the delete all occurrences).
Scratch is made with a low floor, and a high ceiling. Because of the workaround, this block will only raise the floor.
I've already stated it before: No support.
Um, these blocks have just the same difficulty level workarounds:
move () steps

go to [ v]
A:
move () steps
is impossible very hard to workaround.
You mean these:
change x by ()
change y by ()
B: It is made that way so it has a lower floor, while retaining the high ceiling. Scratch is designed to let people new to programming have a good place to start, and still making it possible for great things to be made. I was saying that the block suggested wouldn't be used by newer Scratchers, and still has the workaround. You are talking about is a block used in a ton of projects, and is used by newer Scratchers. In both cases the workaround is for intermediates, but the change X/Y blocks are for everyone.

Last edited by CGRises (July 29, 2015 00:54:26)

TheGuyWithTheHat2
Scratcher
33 posts

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

I was thinking that this would make this easier when making some kind of Cleverbot project, so the AI could say things in response to things people have said before, that would transfer to a cloud list (not sure if they exist yet, might have to check, probably not) and the response list would correspond with the people saying things list.

Powered by DjangoBB