milon

joined 1 year ago
[–] milon@lemm.ee 2 points 1 year ago (5 children)

Why does the for loop return when it hits the end of the function? Isn't the recursive portion already completed in draw(n - 1)? The rest of it is just normal non-recursive code if I understand it correctly.

[–] milon@lemm.ee 1 points 1 year ago (3 children)
[–] milon@lemm.ee 2 points 1 year ago (5 children)

It's supposed to be a pyramid but not my code. It's an example of a recursive function from a CS50 lecture and I'm just trying to understand how the code works line by line.

[–] milon@lemm.ee 2 points 1 year ago
[–] milon@lemm.ee 4 points 1 year ago* (last edited 1 year ago)

Ah ha! Yes, I did check the docs but I think I just glanced over that portion. Be more careful next time. Now that I took another look at the other ctype.h functions, they all return 1 or 0. I think I confused equivalent python built-in functions as those evaluated to true/false. The < is a less than sign but it seems it doesn't render correctly on Lemmy.

[–] milon@lemm.ee 3 points 1 year ago

Sorry. It's in C. Updated post. Yes those are titles. I just included the relevant portions rather than the entire code.

[–] milon@lemm.ee 2 points 1 year ago (5 children)

Ah I see. I had a bad habit of using else if statements instead of else statements because I thought else if could be better in seeing the condition it's testing for so it was clearer. I get the logic is actually different now.

view more: ‹ prev next ›