Return True to Win
alf.nu
alf.nu
NaN === Nan // => false
[] === [] // => false
{} === {} // => false
[1] === [1] // => false
[0] === [0] // => false
I guess i never see the gains in the triple vs double equal sign wars. "0" == 0 && "0" !== 0The NaN example comes directly from IEEE754
The others are based on the fact that the two sides are not referring to the same object. C "equivalents" of your examples:
int x[0], y[0]; x == y; // false
typedef struct {} empty_t; empty_t *x, *y; x == y; // false
int x[] = { 1 }, y[] = { 1 }; x == y; // false
int x[] = { 0 }, y[] = { 0 }; x == y; // falseOne array or object does not equal another, different one.
There are definitely gains - I strongly suggest following the 'moral' of the story.
At least the === paradigm is fairly consistent and mostly rational.
https://jsfiddle.net/5Yzs6/17/
Did you know undefined is equal to undefined, but not <= undefined or >= undefined?
Or that two instances of the same object/array are not equal (e.g. [-1] != [-1]), but are both <= and >= each other?
Or that /.*/ is non-comparable (only != is true) to all numbers, but greater than [-0.5] and "-0.5", and less than [0] and "0"?
By that definition, Brainf*ck[1] also makes sense.
I see:
return true to win
(Come back in a few minutes.)
What do I win?Every time you win, everybody loses.
Anyways, that video is awful and totally wrong. Node code can be clean, threaded code can be ugly. Both can be fast, but the perf characteristics are different (for OS threads, anyways).
"These requirements are a willful violation of the JavaScript specification current at the time of writing. The JavaScript specification requires that ToBoolean return true for all objects, and does not have provisions for objects acting as if they were undefined for the purposes of certain operators. This violation is motivated by a desire for compatibility..." with old Internet Explorer.
Maybe the challenge is to fix HTTP?
In 'object' terms, an empty string is still a string! It's something.
I guess if you think about it from a memory perspective, it's 'nothing'.
But since JS is not actually like C, I really wish "" were true.
However, on mobile the input loses focus after each individual character typed which is quite frustrating.
Did I do it wrong?
And it's whitespace significant, which is something only maniacs like in a programming language.
I'm half joking, don't get too offended...
But whitespace significance is madness.
(Going from memory of the last time I tried this challenge, since I can't get it to load at the moment.)
Boolean Logic and natural languages are pretty mainstream in my opinion. Do you mean programming languages? If IEEE whatsthenumber is implemented in the FPUs to provide fcmp (Floating-point Compare Instruction), the languages don't have much of a choice.
When there are different types of equality, ie. compare instructions, you have no equality. That's maybe a bit binary. I'm sorry, I thought this was Computer Science.
It may not seem obvious and it may seem logically inconsistent but, like you said, this is computer science and things don't always work exactly the way we think they should. Usually because the obvious logical solution has problems when implemented so we change things around. In this case, NaN != NaN because of some of the limitations at the time IEEE 754 was proposed.
> It may not seem obvious and it may seem logically inconsistent but, ...
An if an argument is made in defense of inconsistent logic, how could the argument be expected to be logically consistent?
Your argument by authority is not very good. There are involved explanations on stackoverflow.com, but I didn't bother to read, yet. Another solution would be to set the carry flag.
Equality is domain dependent. For example ∞!=∞ could be justified, as can (0/0)!=(0/0). In the domain of real numbers, equality can be an undecideable problem[1]. I guess the designers of these languages had to choose between tolerable defaults or throwing exceptions. I'm happy with JS doing this:
% node
> 1.0/-0
-Infinity
> 1.0/0
Infinity
> 0/0
NaN
> 0/NaN
NaN
> 1+NaN
NaN
[1] https://math.stackexchange.com/questions/143727/determining-...Page had message that the Hacker News 'hug' was likely to affect performance.
[] - {}
transitive([],0,[])Spoiler here: x=>_=>x=-~x
And also in this link: [1]: https://www.reddit.com/r/programming/comments/4wd32v/return_...
function(c=1){return function(){return c++}}
44 characters(x=0)=>_=>++x
the underscore is another variable but a single variable does not require parenthesis. So instead of two chars for the two parens, you use a single char for a single letter variable. JS FTW ;)
i=>_=>i=-~iPun intended!
Oh, undef is as easy as knowing HTML trivia. Getting a falsey value to return an arbitrary string when invoked as a function is at least a little harder...
> random3
... is almost as easy as random1
> random4
is exactly as impossible as it looks
The whole down voting thing imo really has to go. Just flag answers or up vote. The whole bro intellectual rudeness is sort of off putting.
▷ true
You win!
ReturnTrue:1 Fetch API cannot load https://bigger.alf.nu/db/true/H5VmsyVCBD62113H5Slu. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://alf.nu' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.