Discuss Scratch
- Iditaroid
-
500+ posts
split block
The workarounds are alright, but as long as you can't make custom reporters they'll automatically be less convenient.
- MathlyCat
-
1000+ posts
split block
Just because you say doesn't mean it is. No support, workaroundable.
Also, there's a duplicate out there somewhere.
In other words you literally posted a lie, a very bad and lazy one.
If you can prove it's workaround-able post it. If there's a duplicate post it.
-_-
Support, seems really interesting and useful!
- bluepython
-
2 posts
split block
you could also just do this:…a split block does have a workaround.split [hello world] by [ ] into [list v]
/* have to hack the custom block procDef and call blocks to be able ::grey
to specify an available list without having to type it in every time */ ::grey
define split (string) by (splitter) into (list)
delete (all v) of (list) // have to hack the list blocks
set [split_substr v] to []
set [split_i v] to [0]
if <(splitter) = []> then // empty splitter means split by each letter
repeat (length of (string))
change [split_i v] by (1)
add (letter (split_i) of (string)) to (list)
end
else
repeat (length of (string))
change [split_i v] by (1)
set [split_chr v] to (letter (split_i) of (string))
if <(split_chr) = (splitter)> then
add (split_substr) to (list)
set [split_substr v] to []
else
set [split_substr v] to (join (split_substr)(split_chr))
end
end
if <not <(split_substr) = []>> then // leave no substring unadded
add (split_substr) to (list)
end
enddefine split (character) by (char)
set [repeat v] to [0]
repeat (length of (character))
if <(letter (repeat) of (character)) = (char)> then
add (text) to [final v]
set [text v] to []
end
set [text v] to (join (text) (letter (repeat) of (character))
end
- Charles12310
-
1000+ posts
split block
split string [] into list [list v] :: list
This block splits all the characters of a string into a list without the need to do this:
define split (string) into list (list)
set [c v] to (0)
repeat (length of (string))
change [c v] by (1)
add (letter (c) of (string)) to (list)
This is because not all Scratchers not how to do certain functions that need the “variable loop method”.
It could be useful for many other things such as detection, bypassing join block limits, etc.
There will be no spaces between each item list unless a space is an item on a list.
- -Rex-
-
500+ posts
split block
How often do you need to do this? It's uncommon enough that it doesn't need a new block. And you can't justify a block because not all Scratchers know about the “variable loop method,” because if you could, there would already be hundreds of new blocks.
- DaEpikDude
-
1000+ posts
split block
Personally I think it should work more like the split function in other programming languages (or at least Python):
Say you put in “This is a message”, you get the list “This, is, a, message”.
i.e it splits the words, not the characters.
Say you put in “This is a message”, you get the list “This, is, a, message”.
i.e it splits the words, not the characters.
Last edited by DaEpikDude (Aug. 30, 2017 23:48:26)
- Charles12310
-
1000+ posts
split block
1. Many users use the “variable loop method” in advanced projects in most cases of the usage. How often do you need to do this? It's uncommon enough that it doesn't need a new block. And you can't justify a block because not all Scratchers know about the “variable loop method,” because if you could, there would already be hundreds of new blocks.
2. I'm just saying not everybody knows it. It's not like I'm going to promote every block because their workaround has complicated stuff in it. Even some blocks unnecessary and can be done yourself require the variable loop method.
That would be difficult. Personally I think it should work more like the split function in other programming languages (or at least Python):
Say you put in “This is a message”, you get the list .
i.e it splits the words, not the characters.
- -Rex-
-
500+ posts
split block
So what if not everyone knows the “variable loop method”? It's very common, very useful, and if a Scratcher wishes to be successful, they better learn how to use it. Anyway, if an inexperienced Scratcher needed to split a string, they would probably be able to find a workaround very quickly. 1. Many users use the “variable loop method” in advanced projects in most cases of the usage.
2. I'm just saying not everybody knows it. It's not like I'm going to promote every block because their workaround has complicated stuff in it.
- Charles12310
-
1000+ posts
split block
What about these blocks:So what if not everyone knows the “variable loop method”? It's very common, very useful, and if a Scratcher wishes to be successful, they better learn how to use it. Anyway, if an inexperienced Scratcher needed to split a string, they would probably be able to find a workaround very quickly. 1. Many users use the “variable loop method” in advanced projects in most cases of the usage.
2. I'm just saying not everybody knows it. It's not like I'm going to promote every block because their workaround has complicated stuff in it.
(join [] [] :: operators )
(length of [list v])
(length of [])
They are both existent, and their workarounds require a “variable loop method”. So what? Does that mean they have to be removed? That is not learning. Suggestions are meant to understand users of all ages. This isn't about giving them challenges. That would be like at a school, a teacher gives a calculus test to elementary schoolers.
- TheMonsterOfTheDeep
-
1000+ posts
split block
A much better block is
split [One, two, three] by [,] into [ v] :: listBecause only implementing the easiest to workaround split would be really silly.
- walkcycle
-
500+ posts
split block
Yes. And if Scratch could be simplified to report a list as a list and to add one list to another (without using loops), then it could be a reporter. A much better block issplit [One, two, three] by [,] into [ v] :: listBecause only implementing the easiest to workaround split would be really silly.
split [One, two, three] by [,] :: list reporter // list of three things
add (split [Uno, dos, tres] by [,] :: list ) to [list v] // adds three things to end of list
list [One, two, three] split by [,] :: list reporter // different wording
- -Rex-
-
500+ posts
split block
Those blocks exist because they have much more common uses than the block suggested here, they have more basic functionality, and they would be more annoying to workaround. Scratch doesn't have custom reporters, so any workaround would be cumbersome. What about these blocks:(join [] [] :: operators)
(length of [list v])
(length of [])
They are both existent, and their workarounds require a “variable loop method”. So what? Does that mean they have to be removed?What it is is that they have much more common uses than the block you're suggesting.
That is not learning.What's not learning is being handed an immediate workaround to a block without much use. That would be like at school, an algebra class just tells you to enter equations into a program that solves them instead of you actually solving them yourself and understanding math better. Scratch is about problem solving. If you want to do something that doesn't exist in the language, you make a custom block. The already existing blocks are just tools that help you get there without you having to re-create every commonly-used function. Adding this block would slow learning, because then Scratchers wouldn't have to learn about the “variable loop method,” which is very common. Also, Scratchers are likely to use the “variable loop method” before using lists.
Suggestions are meant to understand users of all ages.This has nothing to do with what I said.
This isn't about giving them challenges.Then how do you expect Scratchers to learn?
That would be like at a school, a teacher gives a calculus test to elementary schoolers.Except it isn't, because Scratchers aren't forced to learn at any rate. They naturally learn more things as they create progressively more complex projects.
- Charles12310
-
1000+ posts
split block
1. What do you mean, the others are used more than this one? This block hasn't even existed yet, so you can't be so sure.Those blocks exist because they have much more common uses than the block suggested here, they have more basic functionality, and they would be more annoying to workaround. Scratch doesn't have custom reporters, so any workaround would be cumbersome. What about these blocks:(join [] [] :: operators)
(length of [list v])
(length of [])They are both existent, and their workarounds require a “variable loop method”. So what? Does that mean they have to be removed?What it is is that they have much more common uses than the block you're suggesting.That is not learning.What's not learning is being handed an immediate workaround to a block without much use. That would be like at school, an algebra class just tells you to enter equations into a program that solves them instead of you actually solving them yourself and understanding math better. Scratch is about problem solving. If you want to do something that doesn't exist in the language, you make a custom block. The already existing blocks are just tools that help you get there without you having to re-create every commonly-used function. Adding this block would slow learning, because then Scratchers wouldn't have to learn about the “variable loop method,” which is very common. Also, Scratchers are likely to use the “variable loop method” before using lists.Suggestions are meant to understand users of all ages.This has nothing to do with what I said.This isn't about giving them challenges.Then how do you expect Scratchers to learn?That would be like at a school, a teacher gives a calculus test to elementary schoolers.Except it isn't, because Scratchers aren't forced to learn at any rate. They naturally learn more things as they create progressively more complex projects.
2. This block would have a common use if the project is was used on isn't easy to function, such as safe chats and real life videos games and etc. Like for example if you wanted to remove an item from a list, which acts are your inventory, a system would need to detect which item # of the list contains the item, and deletes it.
3. I know Scratch isn't a calculator, but sometimes some things can't be done without an easy procedure. I mean, “move () steps” can be simulated.
4. Scratchers need to learn the easiest ways before doing it themselves. You can't expect them to figure out how to make a cloud list in less than a day without teaching them how cloud variables and data work, which would take a lot of time, and yet those lists are going to be added. Move () steps is also complicated, yet it only takes like 6 - 10 blocks to make. If the students learn sine, they might figure a way to simulate. That was why I said not everybody knows how to do the variable loop method, because “it takes time”.
5. Hmm…good point.
- Dragonlord767
-
1000+ posts
split block
Seriously, please add this. It would be so useful for decoding save codes.
Also, no one blame me for necroposting, this is the suggestions section.
Also, no one blame me for necroposting, this is the suggestions section.
- ipaddude
-
100+ posts
split block
support
also i prefer to call it a delimiter and usually delimiters support more than one character
also nobody cares if its workaroundable
how do you expect beginners to understand that workaround?
many other languages have built-in split functions
and as you can't create a function with a return value, split would be useful.
my only concern is that you can't set a list to another list like
oh nice
last last post from 4 years ago
yay
also i prefer to call it a delimiter and usually delimiters support more than one character
also nobody cares if its workaroundable
how do you expect beginners to understand that workaround?
many other languages have built-in split functions
and as you can't create a function with a return value, split would be useful.
my only concern is that you can't set a list to another list like
replace [list v] to (other list)so that might be weird
oh nice
last last post from 4 years ago
yay
Last edited by ipaddude (May 14, 2020 11:42:57)
- ipaddude
-
100+ posts
split block
you can't workaround something that doesnt existIs this workaroundable?Anything is workaroundable. No support, workaroundable.
Also, there's a duplicate out there somewhere.
(well, you g et my point)create file [] at []::customBecause if so, I'd love to hear the workaround. (Seriously, I would really like this.)
wait is necro allowed on suggestions
oof
Last edited by ipaddude (July 19, 2020 14:24:28)
- halochief7
-
17 posts
split block
split [hello world] by [ ] into [list v]
/* have to hack the custom block procDef and call blocks to be able ::grey
to specify an available list without having to type it in every time */ ::grey
define split (string) by (splitter) into (list)
delete (all v) of (list) // have to hack the list blocks
set [split_substr v] to []
set [split_i v] to [0]
if <(splitter) = []> then // empty splitter means split by each letter
repeat (length of (string))
change [split_i v] by (1)
add (letter (split_i) of (string)) to (list)
end
else
repeat (length of (string))
change [split_i v] by (1)
set [split_chr v] to (letter (split_i) of (string))
if <(split_chr) = (splitter)> then
add (split_substr) to (list)
set [split_substr v] to []
else
set [split_substr v] to (join (split_substr)(split_chr))
end
end
if <not <(split_substr) = []>> then // leave no substring unadded
add (split_substr) to (list)
end
end
someone else made this lol
- Rabbit1_1-2
-
32 posts
split block
The split block doesn't have to be a stack block, it could be like this:
Where the first input is the text, the second is the separator.
(split () by ()::operators)
Where the first input is the text, the second is the separator.
- sathvikrias
-
500+ posts
split block
um yes: Support.
(The following was taken from my other suggestion for this block)
Since operators can't return strings, this would be a lists block.split [string] at [i] into [list v] :: lists
It would add to any items already in the list. If the separator was “”, it would split at every letter. If the separator was not in the string, the list would only contain that string.
(join [] [world])