Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Now, (x != 42) which is false yields 0 OK so far. so I have expected to get in console "-42" No. As you say, the expression evolves: (x == 42) * -1 + (x != 42) * x (1) * -1 + (0) * x...
Answer
#3: Post edited
- <blockquote>Now, (x != 42) which is false yields 0</blockquote>
- OK so far.
- <blockquote>so I have expected to get in console "-42"</blockquote>
- No. As you say, the expression evolves:
- <pre>
- (x == 42) * -1 + (x != 42) * x
(1) * -1 + (0) * x-1 + 0- </pre>
- Negative one plus zero is negative one.
- <blockquote>Now, (x != 42) which is false yields 0</blockquote>
- OK so far.
- <blockquote>so I have expected to get in console "-42"</blockquote>
- No. As you say, the expression evolves:
- <pre>
- (x == 42) * -1 + (x != 42) * x
- (1) * -1 + (0) * x
- -1 + 0
- </pre>
- Negative one plus zero is negative one.
#2: Post edited
- <blockquote>Now, (x != 42) which is false yields 0</blockquote>
- OK so far.
- <blockquote>so I have expected to get in console "-42"</blockquote>
- No. As you say, the expression evolves:
- <pre>
- (x == 42) * -1 + (x != 42) * x
(0) * -1 + (0) * x- -1 + 0
- </pre>
- Negative one plus zero is negative one.
- <blockquote>Now, (x != 42) which is false yields 0</blockquote>
- OK so far.
- <blockquote>so I have expected to get in console "-42"</blockquote>
- No. As you say, the expression evolves:
- <pre>
- (x == 42) * -1 + (x != 42) * x
- (1) * -1 + (0) * x
- -1 + 0
- </pre>
- Negative one plus zero is negative one.
#1: Initial revision
<blockquote>Now, (x != 42) which is false yields 0</blockquote> OK so far. <blockquote>so I have expected to get in console "-42"</blockquote> No. As you say, the expression evolves: <pre> (x == 42) * -1 + (x != 42) * x (0) * -1 + (0) * x -1 + 0 </pre> Negative one plus zero is negative one.