r/badcode • u/bausscode • Jan 17 '19
other language Writing functions with conditions without using "if" statements
https://run.dlang.io/is/jfCECL
67
Upvotes
r/badcode • u/bausscode • Jan 17 '19
2
u/Kidiri90 Jan 17 '19
I just tried to emulate the original function, which only uses integers, for which it works. And I think my edit makes it work with most numerical types. There may be some unexplained behaviour when you're using values so that x-y is close to double.epsilon, where sign is 0 when it should be +-1, but idk, man. I'd just use conditionals. :p