Discuss Scratch

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
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]

Yohane0713 wrote:

Support
Did you notice that the topic is from 2014?

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:
Humans must be brought to JUSTICE!
*Lol*
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
<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)
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
by the way, that last part is a general workaround for non-recursive custom reporters. Here is the one for booleans:
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)>

red link
[url=redlink.com][color=red][u]red link[/u][/color][/url]
ScratchDiogoh
Scratcher
1000+ posts

?-Operator [inline if-then-else]

alternative solution
define if <...> then [...] else (... :: #ccc)
if <<...> = [true]> then
set [result v] to (. . . )
else
set [result v] to (. . . :: #ccc)
end

. . . (result) :: grey
no support

+1700 Bad Posts
Mr_PenguinAlex
Scratcher
1000+ posts

?-Operator [inline if-then-else]

theonlygusti wrote:

samanyolu wrote:

MushroomMan99 wrote:

This can be workarounded easily.
if <key [space v] pressed?> then

say [Key space is pressed] for (2) secs
else
say [Key space is not pressed] for (2) secs
end
No support
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.

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?
That's like 4 blocks!

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]

ScratchDiogoh wrote:

alternative solution
define if <...> then [...] else (... :: #ccc)
if <...> then
set [result v] to (. . . )
else
set [result v] to (. . . :: #ccc)
end

. . . (result) :: grey
no support
that's equivalent to this:
(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 link
[url=redlink.com][color=red][u]red link[/u][/color][/url]
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:
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]

red_king_cyclops wrote:

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
Fir the example the OP used, just use this:

TheAdriCoolManDude wrote:

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]

TheAdriCoolManDude wrote:

red_king_cyclops wrote:

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
Fir the example the OP used, just use this:

TheAdriCoolManDude wrote:

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

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)

red link
[url=redlink.com][color=red][u]red link[/u][/color][/url]
Botcho_Otkho
Scratcher
1000+ posts

?-Operator [inline if-then-else]

space_elephant wrote:

does this work?
say(if<>then{if::grey reporter}else{else::grey reporter}::control stack)
How?

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]

Botcho_Otkho wrote:

space_elephant wrote:

does this work?
say(if<>then{if::grey reporter}else{else::grey reporter}::control stack)
How?
by saying the correct value

red link
[url=redlink.com][color=red][u]red link[/u][/color][/url]
Botcho_Otkho
Scratcher
1000+ posts

?-Operator [inline if-then-else]

space_elephant wrote:

Botcho_Otkho wrote:

space_elephant wrote:

does this work?
say(if<>then{if::grey reporter}else{else::grey reporter}::control stack)
How?
by saying the correct value
Next time you're suggesting a workaround, try it on the editor before writing.
[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
arduino_
Scratcher
90 posts

?-Operator [inline if-then-else]

for each [] in []

end

Last edited by arduino_ (Feb. 10, 2019 02:53:10)



Game Maker and Animator :: #F9A148 ring

Powered by DjangoBB