andioop@programming.dev to Programming Horror@programming.devEnglish · edit-27 months agoGod I wish there was an easier way to do thisprogramming.devimagemessage-square21fedilinkarrow-up114arrow-down11
arrow-up113arrow-down1imageGod I wish there was an easier way to do thisprogramming.devandioop@programming.dev to Programming Horror@programming.devEnglish · edit-27 months agomessage-square21fedilink
minus-squareneidu@feddit.nllinkfedilinkarrow-up3·edit-27 months agoMy solution in perl back in the day when I was a teenage hobbyist who didn’t know about the modulus operator: Divide by 2 and use regex to check for a decimal point. if ($num / 2 =~ /\./) { return “odd” } else { return “even” }
minus-squarelysdexic@programming.devlinkfedilinkEnglisharrow-up2·7 months ago Divide by 2 and check for a decimal point. I mean, it ain’t wrong.
My solution in perl back in the day when I was a teenage hobbyist who didn’t know about the modulus operator: Divide by 2 and use regex to check for a decimal point.
if ($num / 2 =~ /\./) { return “odd” }
else { return “even” }
I mean, it ain’t wrong.