Discuss Scratch
- mitdk
-
1000+ posts
split blocks
I would like these blocks:
(part() of split[] on []::operators)This would split a string on a particular character. the part input would tell the block which part of the split should it return. The split character would be deleted, like in python.
(number of parts in split[] on []::operators)
(part(2) of split[a,b,c] on [,]::operators)//bIf you have any further questions, here is a great clarifying post by PkmnQ(edited by me to match new blocks):
Once you understand this block this is more straightforward: There seems to be a lot of confusion over what this does, so I've made a post that can be referred to.(part (1) of split [a.b.c] on [.] :: operators)This simply reports “a”. Think of it as a list, with “.” as a separator.(part (1) of split [a,b] on [.] :: operators)This simply reports “a,b”. It's sort of like a 1-item list.(part (3) of split [a.b] on [.] :: operators)This simply reports an empty string. It acts similarly to this block:(item ( v) of [list v] :: list)
(number of parts in split[] on []::operators)reports how many parts are in a split
(number of parts in split[a.b.c] on [.]::operators)//3
Last edited by mitdk (Feb. 22, 2022 16:39:59)
- mitdk
-
1000+ posts
split blocks
This block could be used like this: please explain more about this block
when green flag clicked
ask [give me a decimal #] and wait
set [num v] to (answer)
say (join [There are] (join (length of (section (2) of split(num) on character[.]::operators)) [decimals after the decimal point]))
Last edited by mitdk (Oct. 1, 2020 18:39:42)
- Vibrato
-
1000+ posts
split blocks
hmm. Interesting. Would the character you split on be put on the first split or the second split? Which character would it be split on if there are multiple of that character?
- mitdk
-
1000+ posts
split blocks
If there are multiple of 1 character (say 2 periods) then you would get 3 sections. As for your other question, I got this idea from python, with the function
split(num, .)
In python, the split character disappears. I would go with that.
split(num, .)
In python, the split character disappears. I would go with that.
Last edited by mitdk (Sept. 25, 2020 19:05:08)
- Vibrato
-
1000+ posts
split blocks
sounds good, and useful. Support. If there are multiple of 1 character (say 2 periods) then you would get 3 sections. As for your other question, I got this idea from python, with the function
split(.)
In python, the split character disappears. I would go with that.
- mitdk
-
1000+ posts
split blocks
More uses for this block can be:
\
\
- Breaking down saving codes
Getting first/last name
breaking down long strings/integers
making a sentence a list of words
Last edited by mitdk (Sept. 26, 2020 00:42:43)
- mitdk
-
1000+ posts
split blocks
If you support, please indicate it. If you don't agree, please tell me why and how i can improve the block idea.
- sportfan999
-
1000+ posts
split blocks
It may seem a little complicated to beginning Scratchers. Sorry, but no support. I may support it if the block name was easier to read.
- mitdk
-
1000+ posts
split blocks
Well, what should i make it? It may seem a little complicated to beginning Scratchers. Sorry, but no support. I may support it if the block name was easier to read.
- mitdk
-
1000+ posts
split blocks
or maybe it would make more sense with some fillers in the block menu? It may seem a little complicated to beginning Scratchers. Sorry, but no support. I may support it if the block name was easier to read.
(section(1) of split[apple, banana] on character[,]::operators)
Last edited by mitdk (Oct. 1, 2020 16:53:59)
- misteray
-
1000+ posts
split blocks
Support, and
A lot of things are complicated to beginning Scratchers. It may seem a little complicated to beginning Scratchers. Sorry, but no support. I may support it if the block name was easier to read.
- sportfan999
-
1000+ posts
split blocks
Yup. A lot of things are complicated to beginning Scratchers.
- sportfan999
-
1000+ posts
split blocks
I created a dumb little project that cuts a bit off of a string. It's right here if anybody here wants to check it out. It is kinda like this suggestion….
- pavcato
-
1000+ posts
split blocks
deleted Because apperently all my posts say “Workaround”.
Last edited by pavcato (Sept. 27, 2020 02:54:57)
- sportfan999
-
1000+ posts
split blocks
deleted
Last edited by sportfan999 (Sept. 27, 2020 19:16:19)
- pavcato
-
1000+ posts
split blocks
You don't need to make a rant because I misunderstood a suggestion.Honestly, half your posts say “Duplicate” or “Workaround”. Maybe consider being a Duplicate.little kinder on the Forums?
Also, that's not even a duplicate. While that post is similar to this, this is a totally different block.Did xXRedTheCoderXx suggest anything like that? I don't think so.when green flag clicked
ask [give me a decimal #] and wait
set [ num] to (answer)
say (join [There are] (join (length of (section (2) of split(num) on character[.])) [decimals after the decimal point]))
Please don't say “Duplicate”, especially when the post you linked isn't even a duplicate!
- sportfan999
-
1000+ posts
split blocks
Sorry, I was a little heated when I wrote that. You don't need to make a rant because I misunderstood a suggestion.