Campbell Ritchie wrote:Here is the simplest version of f() applied to your original code, along with actual type parameters given to the declaration of function:
It should be possible to apply a method reference in line 34 instead: Function::identity.
I just wanted to ask if your solution would still work if I added a check asserting that !Objects.equals(item1, function.apply(item1)) and the same for item2, but then Mike provided the exact solution I had in mind.
Campbell Ritchie wrote:You can create a similar puzzle with NaNs, but all the Boolean tests would have to be reversed.
Campbell Ritchie wrote:I can think of a few things where the usual == and != operators seem to be at odds with equals(), I am keeping quiet about them, too.
It would appear one of my examples where == and != operators seem to be at odds with equals() caused it to print, “Success.” What a surprise!
Campbell Ritchie wrote:I can think of a few things where the usual == and != operators seem to be at odds with equals(), I am keeping quiet about them, too.
It would appear one of my examples where == and != operators seem to be at odds with equals() caused it to print, “Success.” What a surprise!
Campbell Ritchie wrote:And?
You have shown several examples of code which appear to fail. If the idea behind the puzzle is to get it to print, “success,” how are you going to do that?
Stephan van Hulst wrote:you have to expand the character set that it operates on to 32 characters.
If either operand is NaN, then the result of == is false but the result of != is true.
Indeed, the test x!=x is true if and only if the value of x is NaN.
The methods Float.isNaN and Double.isNaN may also be used to test whether a value is NaN.
Not-a-Number values (hereafter abbreviated NaN). A NaN value is used to represent the result of certain invalid operations such as dividing zero by zero. NaN constants of both float and double type are predefined as Float.NaN and Double.NaN.
I'm having hard times to trim up to that.
A NaN value is used to represent the result of certain invalid operations such as dividing zero by zero
Campbell Ritchie wrote:You must be superstitious about using 13, Piet.
Campbell Ritchie wrote:
It seems to be a Caesar cipher.Liutauras Vilda wrote:. . . I never heard of rot13 before . . .