Condition
has attribute HoldAll
which prevents evaluation of its first argument before applying the Condition
. But for some reason Condition
evaluates its first argument even if the test gives False
:
In[1]:= Condition[Print[x],False]
During evaluation of In[1]:= x
Out[1]= Null/;False
Why is this? For what purposes Condition
evaluates its first argument if the test gives False
? In which cases this behavior can be useful?
P.S. Its behavior differs when the Condition
is used as the second argument of SetDelayed
:
In[5]:= f:=Condition[Print[x],False]; f
Out[6]= f
This is what I expected for the all cases.
Conditional questions are those that are not automatically asked: you will have to answer them only depending on your previous answers.
Yes, Google Forms has a conditional questioning feature that will allow you to show questions based on the user's response.
First, select the question. Then click the Add section button on the menu to the right. After you've added the section, click the three dots in the bottom right to add logic to the question by selecting Go to section based on answer. There are now dropdowns to the right of each answer option.
Condition
use often depends on what is in the left hand side, so it must evaluate the LHS at least to some degree. Consider:
MatchQ[3, a_ /; IntegerQ[a]]
True
p = {a_, b_};
MatchQ[{3, 0.2}, p /; IntegerQ[a] && b < 1]
True
Both for this and from this, I would have guessed that Condition
had attribute HoldRest
rather than HoldAll
. It probably needs HoldAll
for some internal use, perhaps related to the SetDelayed
usage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With