andioop@programming.dev to Programming Horror@programming.dev • edit-29 months agoGod I wish there was an easier way to do thisimagemessage-square23 fedilinkarrow-up194
arrow-up194imageGod I wish there was an easier way to do thisandioop@programming.dev to Programming Horror@programming.dev • edit-29 months agomessage-square23 Commentsfedilink
minus-squareneidu@feddit.nlhexbear0·edit-29 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" } linkfedilink
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" }