Wolfram mathematica Matematica If语句

Wolfram mathematica Matematica If语句,wolfram-mathematica,Wolfram Mathematica,在Mathematica中,我使用以下代码: If[ x [[1]] <= 4 && x [[2]] <= 4, "True","False"] True 我不知道如何从代码前一行获取答案,为什么不 If[ x [[1]] <= 4 && x [[2]] <= 4, count++] 如果[x[[1]]为什么不 If[ x [[1]] <= 4 && x [[2]] <= 4, count++] 如果[x[

在Mathematica中,我使用以下代码:

If[ x [[1]] <= 4 && x [[2]] <= 4, "True","False"]
True
我不知道如何从代码前一行获取答案,为什么不

If[ x [[1]] <= 4 && x [[2]] <= 4, count++]
如果[x[[1]]为什么不

If[ x [[1]] <= 4 && x [[2]] <= 4, count++]

如果[x[[1]]你可以将一段代码放在另一段代码中:

If[ 
   If[ x [[1]] <= 4 && x [[2]] <= 4, True, False],
   count=count + 1, count=count
]
If[

如果[x[[1]]按字面意思,您可以将一段代码放在另一段代码中:

If[ 
   If[ x [[1]] <= 4 && x [[2]] <= 4, True, False],
   count=count + 1, count=count
]
If[

如果[x[[1]]除了贝里萨里乌斯的答案外,您还可以考虑:

count += Boole[x[[1]] <= 4 && x[[2]] <= 4]

除了belisarius的回答外,您还可以考虑:

count += Boole[x[[1]] <= 4 && x[[2]] <= 4]

仅我使用mathematica的第二周,但感谢您的创意仅我使用mathematica的第二周,但感谢您的创意在您的代码中实际使用结果分配一个符号,即result=If[…];(…)If[result,…]要在您的代码中实际使用结果分配一个符号,即result=If[…];(…)If[result,…]