programmer_humor·Programmer HumorbyMac isEven APIhttps://isevenapi.xyz/Open linkView original on programming.dev274Comments22
44am lemm.eeIncoming trademark lawsuit from iSeven, the API that tells you if a number is seven or not75
Rikudou_Sage lemmings.world4Hide 4 repliesIf anyone wants a more efficient local version for php: function isEven(int $number): bool { ${1} = false; ${2} = true; while ($number > 2) { $number -= 2; } return $$number; } Edit: Now with support for large numbers! function isEven(int|string $number): bool { ${1} = false; ${2} = true; while (bccomp($number, 2) === 1) { $number = bcsub($number, 2); } $number = (int) $number; return $$number; } Edit 2: someone asked for an ad-supported version, here you go! function isEven(int|string $number): bool { ${1} = false; ${2} = true; while (bccomp($number, 2) === 1) { error_log('Buy isEvenCoin, the hottest new cryptocurrency!'); $number = bcsub($number, 2); } $number = (int) $number; return $$number; } Side note, no more suggestions please, this is getting quite long.55
xxmunk replysh.itjust.worksI fucking love that you managed to use var-vars in a completely key and necessary manner. But please do adhere to the API TOS and throw in an error_log('Buy isEvenCoin, the hottest new cryptocurrency!');14
idunnololz replylemmy.worldThis looks pretty inefficient. You should manually unroll that loop to improve performance.12
mmarcos lemmy.world6Hide 6 repliesOh, bummer, my number isn't supported by the free version: https://api.isevenapi.xyz/api/iseven/8764389587485736749956772984692357867345989845699872561/54
Captain Janeway replylemmy.world2Hide 2 repliesJust divide that number by two until it's small enough to make the request under the free version.47
AAa! replylemmy.worldThat's not even supported by the enterprise version. You're going to need a special agreement with the iseven people to support numbers like that19
ffckreddit replylemmy.ml1Hide 1 replyEasy workaround, just test the last digit. If it is even, the entire number is even, else odd.6
mmarcos replylemmy.worldThat's preposterous! Next time you'll tell me the language I'm using has a builtin operator that test if a number can be divided by another!11
jjubilationtcornpone sh.itjust.works1Hide 1 replyOnly way it could be better is if they threw "AI" in there somewhere.36
jjol replydiscuss.tchncs.deWith the new AI integration, you can get smart isEven results that return the correct answer 90% of the time and a more creative solution 20% of the time.31
eeluvatar programming.dev1Hide 1 replyThe errors are great https://api.isevenapi.xyz/api/iseven/1.5 Sadly it's not always accurate https://api.isevenapi.xyz/api/iseven/0 Edit: nevermind I'm an idiot It's also greatly lacking in number support https://api.isevenapi.xyz/api/iseven/one16
xxmunk replysh.itjust.worksIs even states that it only returns true for even, passing in an odd number is technically unsupported.11
morrowind lemmy.ml1Hide 1 replyI resent that there is a ruby developer included in there. isEven is not idiomatic naming. You should be using #even? from the standard library1
ffckreddit replylemmy.mlSorry sir, most JS developers don’t use standard library functions. We just use npm packages wherever possible.4
Incoming trademark lawsuit from iSeven, the API that tells you if a number is seven or not
If anyone wants a more efficient local version for php:
Edit: Now with support for large numbers!
Edit 2: someone asked for an ad-supported version, here you go!
Side note, no more suggestions please, this is getting quite long.
I fucking love that you managed to use var-vars in a completely key and necessary manner.
But please do adhere to the API TOS and throw in an
error_log('Buy isEvenCoin, the hottest new cryptocurrency!');This looks pretty inefficient. You should manually unroll that loop to improve performance.
Comment edits are the best version control system
I agree! Added new commit to my comment.
Oh, bummer, my number isn't supported by the free version:
https://api.isevenapi.xyz/api/iseven/8764389587485736749956772984692357867345989845699872561/
Just divide that number by two until it's small enough to make the request under the free version.
pretty sure that has to be against their TOS
/sThat's against the terms of math :-)
That's not even supported by the enterprise version. You're going to need a special agreement with the iseven people to support numbers like that
Easy workaround, just test the last digit. If it is even, the entire number is even, else odd.
That's preposterous! Next time you'll tell me the language I'm using has a builtin operator that test if a number can be divided by another!
Only way it could be better is if they threw "AI" in there somewhere.
With the new AI integration, you can get smart isEven results that return the correct answer 90% of the time and a more creative solution 20% of the time.
im glad that people are out there building the web services we truly need.
I love that it works and the ads are pretty good.
The errors are great https://api.isevenapi.xyz/api/iseven/1.5
Sadly it's not always accurate https://api.isevenapi.xyz/api/iseven/0Edit: nevermind I'm an idiotIt's also greatly lacking in number support https://api.isevenapi.xyz/api/iseven/one
Is even states that it only returns true for even, passing in an odd number is technically unsupported.
Funny as hell
I resent that there is a ruby developer included in there.
isEvenis not idiomatic naming. You should be using#even?from the standard librarySorry sir, most JS developers don’t use standard library functions. We just use npm packages wherever possible.