Discuss Scratch
- Discussion Forums
- » Suggestions
- » ?-Operator [inline if-then-else]
- JonathanSchaffer
- Scratcher
1000+ posts
?-Operator [inline if-then-else]
if <this is the workaround::sensing>
set [report v] to [support]
else
set [report v] to [no support]
end
say (report)
club penguin is kil
- iamunknown2
- Scratcher
1000+ posts
?-Operator [inline if-then-else]
Support. It's like lambdas with if/else.
| My website | Using Geany | A Christian | Running Ubuntu MATE 14.04 with Flash 18.0 (release 0) | Search this with quotation marks on Google to view my posts: “ellipsepostpianolizard” (some posts may not show up) |
Moving on from Scratch? Learn Python/a scripting language (e.g Perl, JavaScript), then move on to a C derivative
Moving on from Scratch? Learn Python/a scripting language (e.g Perl, JavaScript), then move on to a C derivative
- Yohane0713
- Scratcher
17 posts
?-Operator [inline if-then-else]
Support
그러니까 요하네라구!!::grey♚♚요하네0713 계산☆기♚♚사용시$$전원 답 제공☜☜리스트사용※ ♜삼각함수 Deg Rad♜모두 지원¥ 키보드사용시 §§삼각함수§§★거듭제곱★소수점사용가능@@@ 즉시이동https://scratch.mit.edu/projects/154608995/
- DaEpikDude
- Scratcher
1000+ posts
?-Operator [inline if-then-else]
Did you notice that the topic is from 2014? 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!
- ArceusJudgement
- Scratcher
5 posts
?-Operator [inline if-then-else]
Support
Arceus said:*Lol*
Humans must be brought to JUSTICE!
when green flag clicked
if <Arceus entered Earth :: operators> then
Bring humans to justice :: control
Use Judgement :: motion
end
- TheAdriCoolManDude
- Scratcher
1000+ posts
?-Operator [inline if-then-else]
Workaroundable, as stated above.
- space_elephant
- Scratcher
500+ posts
?-Operator [inline if-then-else]
support
also what about
but until then here are some workarounds for:
booleans:
also what about
<if<>then<>else<>::operators>
but until then here are some workarounds for:
booleans:
<<<condition::grey>and<if::grey>>or<<not<condition::grey>>and<else::grey>>>one letter strings:
(join(letter<condition::grey>of(if::grey))(letter<not<condition::grey>>of(else::grey)))or hacked blocks
define if<condition>then(if)else(else::custom-arg)by the way, that last part is a general workaround for non-recursive custom reporters. Here is the one for booleans:
if<condition>then//this part is not hacked
set[output v]to(if)
else
set[output v]to(else::custom-arg)
end
(join(letter(0)of(if<condition::grey>then(if::grey)else(else::grey)::stack))(output))//this part is
define if<condition>then<if>else<else::custom-arg>
if<condition>then
set[output v]to<if>
else
set[output v]to<else::custom-arg>
end
<(if<condition::grey>then<if::grey>else<else::grey>::stack)or(output)>
- ScratchDiogoh
- Scratcher
1000+ posts
?-Operator [inline if-then-else]
alternative solution
define if <...> then [...] else (... :: #ccc)no support
if <<...> = [true]> then
set [result v] to (. . . )
else
set [result v] to (. . . :: #ccc)
end
. . . (result) :: grey
+1700 Bad Posts
- Mr_PenguinAlex
- Scratcher
1000+ posts
?-Operator [inline if-then-else]
That's like 4 blocks!Just because a block has a workaround, in this case, an extremely slow, inefficient and annoying workaround, doesn't mean it can't be in Scratch.This can be workarounded easily.if <key [space v] pressed?> thenNo support
say [Key space is pressed] for (2) secs
else
say [Key space is not pressed] for (2) secs
end
Should we remove the not () block because it can be replaced with<(input) = [false]>or the () + () block because it can be worked around with(()-((0)-()))What about the move () steps block?go to x: ((x position) + (([sin v] of (direction)) * (distance) :: operators)) y: ((x position) + (([cos v] of (direction)) * (distance) :: operators)) :: motion
No, we shouldn't remove them; they make Scratch more enjoyable, easier to pick up, easier to use.
So why should we supress this new block just because it also has a complicated workaround?
- TheAdriCoolManDude
- Scratcher
1000+ posts
?-Operator [inline if-then-else]
You could just do this:
forever
if <key [space v] pressed?> then
say [Key Space is pressed!]
else
say [Key Space isn't pressed...]
end
end
- space_elephant
- Scratcher
500+ posts
?-Operator [inline if-then-else]
that's equivalent to this: alternative solutiondefine if <...> then [...] else (... :: #ccc)no support
if <...> then
set [result v] to (. . . )
else
set [result v] to (. . . :: #ccc)
end
. . . (result) :: grey
(x position)*(x position)::stack
set [x v] to (result)
(y position)*(y position)::stack
(result)+(x)::stack
[sqrt v]of(result)::stack
set pen color to(result)
- red_king_cyclops
- Scratcher
500+ posts
?-Operator [inline if-then-else]
The whole point of this suggestion is to make code more concise and efficient. The workaround is only a workaround in functionality; the workaround does not make the code more concise or efficient.
Wouldn't you want to do this:
Support
Wouldn't you want to do this:
say (join [Key space is ] (join (if <key [space v] pressed> then [] else [not ]::control) [pressed.] ) )Instead of this:
if <key [space v] pressed?> then
set [var v] to []
else
set [var v] to [not ]
end
say (join [Key space is ] (join (var) [pressed.] ) )
Support
Last edited by red_king_cyclops (Aug. 29, 2018 11:48:43)
2+2=4
2*2=4
2^2=4
2^^2=4
2^^^2=4
2^^^^2=4
…
I see a pattern.
- TheAdriCoolManDude
- Scratcher
1000+ posts
?-Operator [inline if-then-else]
Fir the example the OP used, just use this: The whole point of this suggestion is to make code more concise and efficient. The workaround is only a workaround in functionality; the workaround does not make the code more concise or efficient.
Wouldn't you want to do this:say (join [Key space is ] (join (if <key [space v] pressed> then [] else [not ]::control) [pressed.] ) )Instead of this:if <key [space v] pressed?> then
set [var v] to []
else
set [var v] to [not ]
end
say (join [Key space is ] (join (var) [pressed.] ) )
Support
You could just do this:forever
if <key [space v] pressed?> then
say [Key Space is pressed!]
else
say [Key Space isn't pressed...]
end
end
- red_king_cyclops
- Scratcher
500+ posts
?-Operator [inline if-then-else]
Fir the example the OP used, just use this: The whole point of this suggestion is to make code more concise and efficient. The workaround is only a workaround in functionality; the workaround does not make the code more concise or efficient.
Wouldn't you want to do this:say (join [Key space is ] (join (if <key [space v] pressed> then [] else [not ]::control) [pressed.] ) )Instead of this:if <key [space v] pressed?> then
set [var v] to []
else
set [var v] to [not ]
end
say (join [Key space is ] (join (var) [pressed.] ) )
SupportYou could just do this:forever
if <key [space v] pressed?> then
say [Key Space is pressed!]
else
say [Key Space isn't pressed...]
end
end
The whole point of this suggestion is to make code more concise and efficient. The workaround is only a workaround in functionality; the workaround does not make the code more concise or efficient.
2+2=4
2*2=4
2^2=4
2^^2=4
2^^^2=4
2^^^^2=4
…
I see a pattern.
- space_elephant
- Scratcher
500+ posts
?-Operator [inline if-then-else]
does this work?
say(if<>then{if::grey reporter}else{else::grey reporter}::control stack)
- Botcho_Otkho
- Scratcher
1000+ posts
?-Operator [inline if-then-else]
How? does this work?say(if<>then{if::grey reporter}else{else::grey reporter}::control stack)
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
- space_elephant
- Scratcher
500+ posts
?-Operator [inline if-then-else]
by saying the correct valueHow? does this work?say(if<>then{if::grey reporter}else{else::grey reporter}::control stack)
- Botcho_Otkho
- Scratcher
1000+ posts
?-Operator [inline if-then-else]
Next time you're suggesting a workaround, try it on the editor before writing.by saying the correct valueHow? does this work?say(if<>then{if::grey reporter}else{else::grey reporter}::control stack)
[offtopic]60 secs rule hi[/offtopic]
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
- MDCCCLXVII
- Scratcher
1000+ posts
?-Operator [inline if-then-else]
Support. For now, there is a workaround:
define if <test> then [true] else [false]
if <test> then
say (true) for (2) secs
else
say (false) for (2) secs
end
- Discussion Forums
- » Suggestions
- » ?-Operator [inline if-then-else]