mastermind@lemm.ee to Programmer Humor@lemmy.ml · 1 year agowhy not a,b or x,y?lemm.eeimagemessage-square95fedilinkarrow-up1602arrow-down142
arrow-up1560arrow-down1imagewhy not a,b or x,y?lemm.eemastermind@lemm.ee to Programmer Humor@lemmy.ml · 1 year agomessage-square95fedilink
minus-squareBilb!@lem.monsterlinkfedilinkarrow-up3arrow-down5·edit-21 year agoWTF, I have never used nor seen “j.” I don’t usually have to name these variables these days though. Pretty much everything I use has foreach or some functional programming type stuff. And like that, the off-by-one mistakes disappear.
minus-squareSaratogaCx@lemmy.worldlinkfedilinkEnglisharrow-up3·1 year agoIt was very common in text books when showing nested loops int nWhatTheCount = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < i; j++) { for (int k = 0; k < j; k++) { for (int l = 0; l < k; l++) { // and on, and on nWhatTheCount++; } } } }
WTF, I have never used nor seen “j.”
I don’t usually have to name these variables these days though. Pretty much everything I use has foreach or some functional programming type stuff.
And like that, the off-by-one mistakes disappear.
j
is for a loop in a loop.It was very common in text books when showing nested loops
int nWhatTheCount = 0; for (int i = 0; i < 10; i++) { for (int j = 0; j < i; j++) { for (int k = 0; k < j; k++) { for (int l = 0; l < k; l++) { // and on, and on nWhatTheCount++; } } } }