Discuss Scratch
- DaEpikDude
- Scratcher
1000+ posts
New list functions!
I'd like to see two new list functions added to Scratch that would make some things easier:
For example: if you have a list with values 3, 5, 2 and you sort small to large, it becomes 2, 3, 5.
Or if you have list banana, apple, orange and sort large to small, it would be orange, banana, apple.
(Symbols are treated smaller than letters, letters smaller than numbers. So sorted list 15, =P, spam would become =P, spam, 15.)
The second suggestion finds the position of something in a list. So if you have list orange, banana, apple and you run code that looks like:
The dropdown would have first and last, so if you ran the same code on a list apple, banana, banana, orange, you would get apple, carrot, banana, orange. Writing in a number would let you choose specifically which one you want, for example:
Edit: I made workarounds to these suggestions: you can find them here.
sort list [bar v] in style [smallest to greatest v]::listThe first suggestion would sort the elements of the list (symbols - letters - numbers) from large to small or small to large.
sort list [bar v] in style [greatest to smallest v]::list
(position of [first v] element [foo] in list [bar v]::list)
For example: if you have a list with values 3, 5, 2 and you sort small to large, it becomes 2, 3, 5.
Or if you have list banana, apple, orange and sort large to small, it would be orange, banana, apple.
(Symbols are treated smaller than letters, letters smaller than numbers. So sorted list 15, =P, spam would become =P, spam, 15.)
The second suggestion finds the position of something in a list. So if you have list orange, banana, apple and you run code that looks like:
replace item (position of [first v] element [banana] in list [bar v]::list) of [bar v] with [carrot]the list would become orange, carrot, apple.
The dropdown would have first and last, so if you ran the same code on a list apple, banana, banana, orange, you would get apple, carrot, banana, orange. Writing in a number would let you choose specifically which one you want, for example:
(position of [3 v] element [foo] in list [bar v]::list)would give you the third instance of foo in the list bar.
Edit: I made workarounds to these suggestions: you can find them here.
Last edited by DaEpikDude (July 23, 2017 10:31:54)
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!
- MineLox92Videos
- Scratcher
100+ posts
New list functions!
I'd like to see two new list functions added to Scratch that would make some things easier:sort list [bar v] in style [small to large v]::listThe first suggestion would sort the elements of the list (symbols - letters - numbers) from large to small or small to large.
sort list [bar v] in style [large to small v]::list
(position of element [foo] in list [bar v]::list)
For example: if you have a list with values 3, 5, 2 and you sort small to large, it becomes 2, 3, 5.
Or if you have list banana, apple, orange and sort large to small, it would be orange, banana, apple.
(Symbols are treated smaller than letters, letters smaller than numbers. So sorted list 15, =P, spam would become =P, spam, 15.)
The second suggestion finds the position of something in a list. So if you have list orange, banana, apple and you run code that looks like:replace item (position of element [banana] in list [bar v]::list) of [bar v] with [carrot]the list would become orange, carrot, apple.
That would help, but there are work arounds.
For the second suggestion:
replace item <[list v] contains [banana] ?> of [list v] with [carrot]
I can't think of workarounds for he first one, though.
But, I support.
Last edited by MineLox92Videos (July 21, 2017 15:16:02)
- DaEpikDude
- Scratcher
1000+ posts
New list functions!
I tried that just now. For the second suggestion:replace item <[list v] contains [banana] ?> of [list v] with [carrot]
I had a list apple, banana, orange, and when I ran the program it became carrot, banana, orange. It should become apple, carrot, orange.
Still, thanks for the support!
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!
- FancyFoxy
- Scratcher
500+ posts
New list functions!
sort [list v] in style [least to greatest v] :: listSupport! (Changed the wording a little)
(position of item [foo] in [list v] :: list)Support if:
(position of (first v) item [foo] in [list v] :: list) // drop-down has "last", and you can put numbers like 2 to mean second, 4 to mean fourth, etc.
THIS IS MY SIGNATURE. THIS MEANS IT IS AN AUTOMATIC MESSAGE THAT APPEARS AT THE BOTTOM OF ALL MY POSTS.
Hi! I'm FancyFoxy! I create animations and games that were never, EVER meant to be taken seriously.
FancyFoxy Heroes and #Thanksgiving are some of my latest projects, check them out!
- DaEpikDude
- Scratcher
1000+ posts
New list functions!
Ooh, yeah, that's a good idea. I'll put that in the post!
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!
- FancyFoxy
- Scratcher
500+ posts
New list functions!
-snip-
That would help, but there are work arounds.
For the second suggestion:replace item <[list v] contains [banana] ?> of [list v] with [carrot]
I can't think of workarounds for he first one, though.
But, I support.
That's not a workaround.
That would just replace the item “true” or the item “false” of the list.
And obviously, it only works for numbers.
THIS IS MY SIGNATURE. THIS MEANS IT IS AN AUTOMATIC MESSAGE THAT APPEARS AT THE BOTTOM OF ALL MY POSTS.
Hi! I'm FancyFoxy! I create animations and games that were never, EVER meant to be taken seriously.
FancyFoxy Heroes and #Thanksgiving are some of my latest projects, check them out!
- yzyzyz
- Scratcher
500+ posts
New list functions!
Support! I also want
(Amount of item [item] in [list v] :: list)to be a thing. I will make a seperate topic about it later.
Last edited by yzyzyz (July 22, 2017 09:18:14)
hi! I'm yzyzyz, the owner of the #bring_it_back studio, a sticky, 400+ projects and 500+ posts.
I am an active scratcher.
advertise in my signature!
ad:Urgently need a popular animation? If you do, check out Every Time I Share A Project, by Randomness-TV!
I am an active scratcher.
advertise in my signature!
ad:Urgently need a popular animation? If you do, check out Every Time I Share A Project, by Randomness-TV!
- PkmnQ
- Scratcher
1000+ posts
New list functions!
For the sort list block, I show some sorting algorithms I'd like to see two new list functions added to Scratch that would make some things easier:here.sort list [bar v] in style [smallest to greatest v]::listThe first suggestion would sort the elements of the list (symbols - letters - numbers) from large to small or small to large.
sort list [bar v] in style [greatest to smallest v]::list
(position of [first v] element [foo] in list [bar v]::list)
For example: if you have a list with values 3, 5, 2 and you sort small to large, it becomes 2, 3, 5.
Or if you have list banana, apple, orange and sort large to small, it would be orange, banana, apple.
(Symbols are treated smaller than letters, letters smaller than numbers. So sorted list 15, =P, spam would become =P, spam, 15.)
The second suggestion finds the position of something in a list. So if you have list orange, banana, apple and you run code that looks like:replace item (position of [first v] element [banana] in list [bar v]::list) of [bar v] with [carrot]the list would become orange, carrot, apple.
The dropdown would have first and last, so if you ran the same code on a list apple, banana, banana, orange, you would get apple, carrot, banana, orange. Writing in a number would let you choose specifically which one you want, for example:(position of [3 v] element [foo] in list [bar v]::list)would give you the third instance of foo in the list bar.
For the second while being used in the block, just use a list item counter and once you get to the correct item, replace that item.
For the second on its own, just use a list item counter and increment a variable until you get it to the correct amount.
Semi-support, there are workarounds, but they are not easy.
This is an account that exists.
Here, have a useful link:
The Official List of Rejected Suggestions by Za-Chary
- DaEpikDude
- Scratcher
1000+ posts
New list functions!
-snip-
For the sort list block, I show some sorting algorithms here.
For the second while being used in the block, just use a list item counter and once you get to the correct item, replace that item.
For the second on its own, just use a list item counter and increment a variable until you get it to the correct amount.
Semi-support, there are workarounds, but they are not easy.
I looked at the project, and I don't really understand it. Maybe you should add something to tell you what it's doing?
As for incrementing a variable, Scratch takes time to process everything so it would take a long time if you had a long list of objects.
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!
- FancyFoxy
- Scratcher
500+ posts
New list functions!
You can run a custom block without screen refresh and it will work instantly.-snip-
For the sort list block, I show some sorting algorithms here.
For the second while being used in the block, just use a list item counter and once you get to the correct item, replace that item.
For the second on its own, just use a list item counter and increment a variable until you get it to the correct amount.
Semi-support, there are workarounds, but they are not easy.
I looked at the project, and I don't really understand it. Maybe you should add something to tell you what it's doing?
As for incrementing a variable, Scratch takes time to process everything so it would take a long time if you had a long list of objects.
Still supporting.
THIS IS MY SIGNATURE. THIS MEANS IT IS AN AUTOMATIC MESSAGE THAT APPEARS AT THE BOTTOM OF ALL MY POSTS.
Hi! I'm FancyFoxy! I create animations and games that were never, EVER meant to be taken seriously.
FancyFoxy Heroes and #Thanksgiving are some of my latest projects, check them out!
- Blaze349
- Scratcher
1000+ posts
New list functions!
No support. You can implement a basic bubblesort in Scratch easily (or an insertion sort).
- DaEpikDude
- Scratcher
1000+ posts
New list functions!
Necessary bump is necessary.
I liked this idea.
I liked this idea.
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!
- walkcycle
- Scratcher
500+ posts
New list functions!
semi-support for 'sort' block
and find position of element in the list
this could return a list for more than one
then put in second input
semi- because maybe a Scracher should learn to program these
[bubble v] sort [list v] from [big to small v] :: list
sort [list v] from [big to small v] with [bubble v] method :: list
sort [list v] from [big to small v] with [bubble v] algorithm :: list
and find position of element in the list
(places in [list v] of [thing] :: list)
this could return a list for more than one
then put in second input
(item ( v) of [list v] :: list)
(item ( v) of (places in [list v] of [thing] :: list) :: list)
semi- because maybe a Scracher should learn to program these
- DaEpikDude
- Scratcher
1000+ posts
New list functions!
'sort' blockYes, a Scratcher should probably try to make these, but usually there's some form of array sort and index finder in other languages. semi-support for[bubble v] sort [list v] from [big to small v] :: listsort [list v] from [big to small v] with [bubble v] method :: list
sort [list v] from [big to small v] with [bubble v] algorithm :: list
and find position of element in the list(places in [list v] of [thing] :: list)
this could return a list for more than one
then put in second input(item ( v) of [list v] :: list)
(item ( v) of (places in [list v] of [thing] :: list) :: list)
semi- because maybe a Scracher should learn to program these
Also, there's no reason for the “sort” function to not just use quicksort: bubblesort is HORRIBLY inefficient.
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!
- TheUltimatum
- Scratcher
1000+ posts
New list functions!
Your sort block can be made better this way:
It would require a function with two inputs. That returns either the first or last depending on certain conditions in the function.sort [list v] with function (foo () ()::custom) ::list
Last edited by TheUltimatum (Oct. 12, 2017 19:39:03)
- DaEpikDude
- Scratcher
1000+ posts
New list functions!
bump
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!
- DaEpikDude
- Scratcher
1000+ posts
New list functions!
bump again
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!
- hellounicorns2
- Scratcher
1000+ posts
New list functions!
Support because it would make lists more useful and let newer scratchers make better games without learning how to make complicated custom blocks
inactive :)
- Botcho_Otkho
- Scratcher
1000+ posts
New list functions!
There is a workaround for:
But support for the other one. That would certainly help when you have a lot of items in your list and you have to find a certain element.
position of (first v) element [foo] in list [list v]::list reporterwhich is:
...::gray hatand its position is the value of the var count.
set [count v] to [0]
repeat until <(item (count) of [list v]) = [banana]>//replace "banana" with your item
change [count v] by (1)
end
...
But support for the other one. That would certainly help when you have a lot of items in your list and you have to find a certain element.
Last edited by Botcho_Otkho (March 5, 2018 17:11:45)
I see now that the circumstances of one's birth are irrelevant. It is what you do with the gift of life that determines who you are. - Mewtwo
- -ShadowOfTheFuture-
- Scratcher
1000+ posts
New list functions!
Support for all. While I know there are workarounds, it would still be very convenient to have these. Other languages have the ability to do these things, why not Scratch?
Not a workaround, this would replace item 1 if it was true, not the item number of “banana”.
-snip-
That would help, but there are work arounds.
For the second suggestion:replace item <[list v] contains [banana] ?> of [list v] with [carrot]
I can't think of workarounds for he first one, though.
But, I support.
Not a workaround, this would replace item 1 if it was true, not the item number of “banana”.
<Insert uncreative signature here>
██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██
███ ███ ██ ████ ██ ███ ███
█████████ █████ █████ █████████
“Though the seasons come and go, and sunshine turns to snow, we will always have tomorrow up ahead.”