Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Several people have given you the right answer; here's an explanation of why your attempts didn't work.</p> <p><strong>Why <code>A[0] &amp;&amp; A[1] &amp;&amp; A[2] &amp;&amp; A[3] == A[4]</code> didn't work:</strong></p> <p>The expression <code>A &amp;&amp; B</code> will evaluate to 0 if either <code>A</code> or <code>B</code> are zero, or to 1 if both <code>A</code> and <code>B</code> are non-zero. The <code>&amp;&amp;</code> operator is left-associative, meaning expressions like <code>A &amp;&amp; B &amp;&amp; C</code> are parsed as <code>(A &amp;&amp; B) &amp;&amp; C</code>; IOW, <code>C</code> is AND-ed with the <em>result</em> of <code>A &amp;&amp; B</code> (0 or 1). Thus, <code>A[0] &amp;&amp; A[1] &amp;&amp; A[2] &amp;&amp; A[3] == A[4]</code> will only evaluate to true if all of <code>A[0]</code> through <code>A[3]</code> are non-zero <em>and</em> <code>A[4]</code> == 1, or any one of <code>A[0]</code> through <code>A[3]</code> are 0 <em>and</em> <code>A[4]</code> == 0. Also note that the <code>&amp;&amp;</code> operator won't evaluate the right-hand operand if the left-hand operand is 0. </p> <p><strong>Why <code>(A[0]),(A[1]),(A[2]),(A[3]) == (A[4])</code> didn't work:</strong></p> <p>The comma operator evaluates each expression in sequence, and the result is the value of the <em>last</em> expression, so only the value of <code>A[3]</code> is being compared to <code>A[4]</code>. Each of <code>A[0]</code> through <code>A[2]</code> is evaluated, but the result is discarded. </p> <p><strong>Why <code>(A[0]) == (A[1]) == (A[2]) == (A[3]) == (A[4])</code> didn't work:</strong></p> <p>Similar to the <code>&amp;&amp;</code> operator, the result of <code>A == B</code> will be 0 or 1. Also similar to the above, the <code>==</code> operator is left-associative, so <code>A == B == C</code> is parsed as <code>(A == B) == C</code>, so <code>C</code> is being compared to the result of <code>A == B</code>, which will be either 0 or 1. So the above will only evaluate to true if <code>A[0]</code> and <code>A[1]</code> are the same, and <code>A[2]</code> through <code>A[4]</code> all equal 1. </p> <p>Therefore, if you want to check that multiple expressions are all equivalent, you must write something like</p> <pre><code>A == B &amp;&amp; B == C &amp;&amp; C == D </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload