this post was submitted on 12 Sep 2025
444 points (98.9% liked)

Programmer Humor

26328 readers
1468 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] FiskFisk33@startrek.website 6 points 2 days ago* (last edited 2 days ago) (1 children)
isEven(0) ->
    true;
isEven(Num) ->
    isOdd(Num-1).
isOdd(0) ->
    false;
isOdd(Num) ->
    isEven(Num-1).
[–] Knock_Knock_Lemmy_In@lemmy.world 3 points 2 days ago* (last edited 2 days ago) (1 children)

Hmm.

isEven(-2)...<out of stack error>

[–] killingspark@feddit.org 3 points 2 days ago

Nah, tail recursion optimization can just reuse the same stack frame again and again. It's going to loop until it wraps around what ever integer width it has and then tells you if the biggest integer is even or odd. Or, if it's nice, it's going to complain about the wrap around