Discuss Scratch
- Discussion Forums
- » Suggestions
- » [ ] contains [ ]?
- AwesomePerson238243
-
100+ posts
[ ] contains [ ]?
I have a suggestion for a new block.
name: contains ?
category: sensing
type: Boolean
function: it would scan the first string to see if it contained the second strings input. if it did, it would come out true
block:
people who support (14):
Lythium
DownsGameClub
DaSpudLord
SpongyGames
pvz_pro
theonlygusti
Zekrom01
BurnedCrystal
sheep_maker
alexphan
Bookowl
Prscr
JonathanSchaffer
A-no-meep
Gooballs
people who don't support (0):
name: contains ?
category: sensing
type: Boolean
function: it would scan the first string to see if it contained the second strings input. if it did, it would come out true
block:
< [ ] contains [ ] ? :: sensing Boolean >
people who support (14):
Lythium
DownsGameClub
DaSpudLord
SpongyGames
pvz_pro
theonlygusti
Zekrom01
BurnedCrystal
sheep_maker
alexphan
Bookowl
Prscr
JonathanSchaffer
A-no-meep
Gooballs
people who don't support (0):
Last edited by AwesomePerson238243 (April 22, 2016 19:56:55)
- Lythium
-
1000+ posts
[ ] contains [ ]?
I actually support now, because I can't seem to find a valid workaround.
Last edited by Lythium (April 9, 2016 13:45:33)
- AwesomePerson238243
-
100+ posts
[ ] contains [ ]?
what is the easy workaround?<(answer) = [ whatever]>
Easy workaround.
- DownsGameClub
-
1000+ posts
[ ] contains [ ]?
<(answer) = [ whatever]>
Easy workaround.
Uhh…. That doesnt work.
Support. But a quick revision
<[] contains []?>::sensing // The entire block is supposed to be blue... =/Since this version of programming is somewhat like a sentence, and saying “if does (answer) contains (blank)”
Last edited by DownsGameClub (April 9, 2016 12:49:46)
- Lythium
-
1000+ posts
[ ] contains [ ]?
I realised it after posting.<(answer) = [ whatever]>
Easy workaround.
Uhh…. That doesnt work.
Support. But a quick revision<[] contains []?>::sensing // The entire block is supposed to be blue... =/Since this version of programming is somewhat like a sentence, and saying “if does (answer) contains (blank)”
- pvz_pro
-
500+ posts
[ ] contains [ ]?
<[] contains [] ?::sensing>Support.
reasons? Support
semi-support, this has a workaround with variables and lists
- theonlygusti
-
1000+ posts
[ ] contains [ ]?
Okay, for the record, here is the work-around: semi-support, this has a workaround with variables and lists
set [substring found? v] to [false]
set [letters found v] to [0]
set [i v] to [1]
repeat until <<(length of (string)) = ((i)+(1))> or <(substring found?) = [true]>>
set [j v] to [1]
repeat until <<(length of (substring)) = ((j)+(1))> or <(substring found?) = [true]>>
if <(letter (j) of (substring)) = (letter ((i)+((j)-(1))) of (string))> then
change [letters found v] by (1)
end
change [j v] by (1)
end
if <(letters found) = (length of (substring))> then
set [substring found? v] to [true]
end
change [i v] by (1)
end
if <(substring found?) = [true]> then
else
end
As you can see, it is very simple and intuitive, especially for new scratchers.</sarcasm>
I don't see any reason not to support this idea, so, yeah, support!
- BurnedCrystal
-
100+ posts
[ ] contains [ ]?
Support, as the workaround can have a considerable effect on performance.
That and I'm sure no one wants to redefine string manipulation functions that already exist in other languages
That and I'm sure no one wants to redefine string manipulation functions that already exist in other languages
- Scratcher1002
-
1000+ posts
[ ] contains [ ]?
For the block to be blue you have to put it inside the brackets.<(answer) = [ whatever]>
Easy workaround.
Uhh…. That doesnt work.
Support. But a quick revision<[] contains []? :: sensing> // The entire block is supposed to be blue... =/Since this version of programming is somewhat like a sentence, and saying “if does (answer) contains (blank)”
- alexphan
-
1000+ posts
[ ] contains [ ]?
Although you can simply add all of the letters into a list, and then using this:
Support.
<[ v] contains [ ]>It would be very useful for finding substrings.
Support.
- BookOwl
-
1000+ posts
[ ] contains [ ]?
That only works if your looking for a single letter… Although you can simply add all of the letters into a list, and then using this:<[ v] contains [ ]>It would be very useful for finding substrings.
Support.
Support
- theonlygusti
-
1000+ posts
[ ] contains [ ]?
That doesn't work. Although you can simply add all of the letters into a list, and then using this:<[ v] contains [ ]>It would be very useful for finding substrings.
Support.
Only this works:
Okay, for the record, here is the work-around: semi-support, this has a workaround with variables and listsset [substring found? v] to [false]
set [letters found v] to [0]
set [i v] to [1]
repeat until <<(length of (string)) = ((i)+(1))> or <(substring found?) = [true]>>
set [j v] to [1]
repeat until <<(length of (substring)) = ((j)+(1))> or <(substring found?) = [true]>>
if <(letter (j) of (substring)) = (letter ((i)+((j)-(1))) of (string))> then
change [letters found v] by (1)
end
change [j v] by (1)
end
if <(letters found) = (length of (substring))> then
set [substring found? v] to [true]
end
change [i v] by (1)
end
if <(substring found?) = [true]> then
else
end
As you can see, it is very simple and intuitive, especially for new scratchers.</sarcasm>
I don't see any reason not to support this idea, so, yeah, support!
- Prscr
-
100+ posts
[ ] contains [ ]?
<[] contains [] ?::sensing>
I support. I can't find an easy way to workaround this (above seems to have a workaround)
So, final answer,
support!::sensing
Last edited by Prscr (April 9, 2016 21:13:55)
- pvz_pro
-
500+ posts
[ ] contains [ ]?
the scratch block's strings are not case sensitive Support if it's case sensitive.
- alexphan
-
1000+ posts
[ ] contains [ ]?
I also defenitely support for that. That would make case detection SO much easier.the scratch block's strings are not case sensitive Support if it's case sensitive.
- Discussion Forums
- » Suggestions
-
» [ ] contains [ ]?