Discuss Scratch

UnsungCress
Scratcher
28 posts

Make the 'for each' loop available in the block palette

It's already in the editor (if you hack it in) and it's perfectly functional, so why not just add it into the palette without having to go through the extra effort of hacking in the block or backpacking it from someone else?
It would be more convenient and would save a lot of trouble.
-Sound_Effect-
Scratcher
66 posts

Make the 'for each' loop available in the block palette

It's the same as a Repeat block. It's easier for people of a younger age to understand.

repeat ()

end

Check out: https://en.scratch-wiki.info/wiki/For_Each_()_in_()_(block) - It's the wiki page for the For Each Loop.
MagicCoder330
Scratcher
1000+ posts

Make the 'for each' loop available in the block palette

-Sound_Effect- wrote:

It's the same as a Repeat block. It's easier for people of a younger age to understand.

repeat ()

end

Check out: https://en.scratch-wiki.info/wiki/For_Each_()_in_()_(block) - It's the wiki page for the For Each Loop.

Its sort of like a repeat block, but it is a bit different. A repeat block just repeats a certain amount of times, while the for each () in () block repeats it for every () in (). For instance, if the first number is 5 and the second is 15, it will repeat 3 times. I agree that it isn't the most useful thing in existence, but it has some use.
UnsungCress
Scratcher
28 posts

Make the 'for each' loop available in the block palette

Well yes, but using the for loop would be more convenient for those who do know how it works.
KingRat_1
Scratcher
100+ posts

Make the 'for each' loop available in the block palette

MagicCoder330 wrote:

-Sound_Effect- wrote:

It's the same as a Repeat block. It's easier for people of a younger age to understand.

repeat ()

end

Check out: https://en.scratch-wiki.info/wiki/For_Each_()_in_()_(block) - It's the wiki page for the For Each Loop.

Its sort of like a repeat block, but it is a bit different. A repeat block just repeats a certain amount of times, while the for each () in () block repeats it for every () in (). For instance, if the first number is 5 and the second is 15, it will repeat 3 times. I agree that it isn't the most useful thing in existence, but it has some use.
would
((15) / (5))
not do the same thing?

Last edited by KingRat_1 (Dec. 5, 2023 18:47:00)

UnsungCress
Scratcher
28 posts

Make the 'for each' loop available in the block palette

MagicCoder330 wrote:

-Sound_Effect- wrote:

It's the same as a Repeat block. It's easier for people of a younger age to understand.

repeat ()

end

Check out: https://en.scratch-wiki.info/wiki/For_Each_()_in_()_(block) - It's the wiki page for the For Each Loop.

Its sort of like a repeat block, but it is a bit different. A repeat block just repeats a certain amount of times, while the for each () in () block repeats it for every () in (). For instance, if the first number is 5 and the second is 15, it will repeat 3 times. I agree that it isn't the most useful thing in existence, but it has some use.

In my experience, it works like
set [amount v] to [0]
repeat ( amount )
change [amount v] by (1)
end

but in a single loop. For example, if you did this

for each [amount v] in (5){ 
move (amount) steps
} :: control
then the sprite would move 1 step, then 2, 3 4 and 5.

MagicCoder300, you're thinking of
repeat ( () / () )

end
yadayadayadagoodbye
Scratcher
1000+ posts

Make the 'for each' loop available in the block palette

UnsungCress wrote:

In my experience, it works like
set [amount v] to [0]
repeat ( amount )
change [amount v] by (1)
end
Actually, you would do
set [i v] to [1]
repeat until <[5] < (i)>
change [i v] by (1)
end
to imitate a for loop (obviously, make the change i value increase to have it go faster and stuff)
UnsungCress
Scratcher
28 posts

Make the 'for each' loop available in the block palette

yadayadayadagoodbye wrote:

Actually, you would do
set [i v] to [1]
repeat until <[5] < (i)>
change [i v] by (1)
end
to imitate a for loop (obviously, make the change i value increase to have it go faster and stuff)
They both do pretty much the same thing.
EDawg2011
Scratcher
1000+ posts

Make the 'for each' loop available in the block palette

Children probably won't understand this block, so it might get renamed to something like “(variable name) count to (input)”
(Someone please tell me how to make a custom C block. (Edit: in a forum post.))
Another edit: I found it out.
[x v] count to (){

} :: control
3rd edit: Fixed block.

Last edited by EDawg2011 (Dec. 5, 2023 22:09:18)

IndexErrorException
Scratcher
500+ posts

Make the 'for each' loop available in the block palette

Support, don't rename. I already use this block in most of my programs, it takes a couple steps out.
unmissable
Scratcher
1000+ posts

Make the 'for each' loop available in the block palette

Support because it can actually be useful
And it's not like they're going to need to code it since it already exists
edit:typo

Last edited by unmissable (Dec. 5, 2023 23:31:52)

EDawg2011
Scratcher
1000+ posts

Make the 'for each' loop available in the block palette

IndexErrorException wrote:

Support, don't rename. I already use this block in most of my programs, it takes a couple steps out.
It would need to be renamed because its name is very vague. wdym by “for each (foo v) in (n)” Does it divide “n” by “foo” and repeat it that many times, or does it do something for each time the “n” is contained in “foo”? It's confusing, and I didn't even know how it worked.
Scratchedbyyou
Scratcher
100+ posts

Make the 'for each' loop available in the block palette

Support, I use the workaround a lot and it's getting annoying, I also don't want to get my project marked as nfe for using the removed block in a project either.
EDawg2011
Scratcher
1000+ posts

Make the 'for each' loop available in the block palette

bump
ajskateboarder
Scratcher
1000+ posts

Make the 'for each' loop available in the block palette

EDawg2011 wrote:

IndexErrorException wrote:

Support, don't rename. I already use this block in most of my programs, it takes a couple steps out.
It would need to be renamed because its name is very vague. wdym by “for each (foo v) in (n)” Does it divide “n” by “foo” and repeat it that many times, or does it do something for each time the “n” is contained in “foo”? It's confusing, and I didn't even know how it worked.
This is how almost every language has named for loops

Also, this is a very related suggestion: https://scratch-mit-edu.ezproxyberklee.flo.org/discuss/topic/204415/
ToastRoastBoast
Scratcher
500+ posts

Make the 'for each' loop available in the block palette

No_Normal
Scratcher
100+ posts

Make the 'for each' loop available in the block palette

-Sound_Effect- wrote:

It's the same as a Repeat block. It's easier for people of a younger age to understand.

repeat ()

end

Check out: https://en.scratch-wiki.info/wiki/For_Each_()_in_()_(block) - It's the wiki page for the For Each Loop.
No, the repeat block has its own use, I wish there was a for each in i, because it is really helpful and some of my projects are slow because the workaround adds a bunch of blocks.
RediblesQW_Doors
Scratcher
38 posts

Make the 'for each' loop available in the block palette

for each [var v] in (…){
}::control

Last edited by RediblesQW_Doors (Dec. 17, 2023 13:27:59)

ichan2
Scratcher
2 posts

Make the 'for each' loop available in the block palette

Sorry i posted something but it was wrong

Last edited by ichan2 (April 11, 2024 10:47:57)

banana439monkey
Scratcher
1000+ posts

Make the 'for each' loop available in the block palette

and maybe even a
range between () and () :: list reporter
block?

Banana

Powered by DjangoBB