0
I now challenged myself little to develop a function that returns if a number is greater than 5 without the use of any comparison operator, as assertion, while, ternary operator, if which directly or indirectly compares the given number with 5.
Return could be True/False or 0/1.
I tried using bitwise operators, but I was not successful and not even a "Clue" with it.
This is basically a hack, but it’s the same thing, basically (a-5 == 5-5)
– Breno
So I don’t even understand what you want, is there an example of what you want in other language? The thing is, after the expression, he gets the first one if he goes
True
and evaluate the rest, or just returnFalse
.– user142809
I said up there: "without the use of any comparison operator, as [...] comparing directly or indirectly the given number with 5."
– Breno
I guess there’s no way so you can even invent another function with a character that directly compares numbers. Like in these functional languages you can even create a function that accepts an argument and compares with a number (with little Boilerplate), but inside it will still have a
== ou > ou <=
. An example in Haskell would be to mount a function that accepts a number and returns a bool, then calls it with the number you want to compare, the syntax would befn 2
to compare the 2 for example, then the function would befn x = x > 5
. But it’s not even for code golfing.– user142809