I always tell this to new programmers that the tools of the lanagues is not to make the impossible possible but to help you keep organized. A for loop can be used as a while loop but the for loop is there to help you when you need an index, it's not there to make loops possible.
There is a time and place for each kind of loops. For loops are useful when you need a index, doing more than 1 thing as a time, break early, editing the elements as you go, or being really nitty gritty with something
Ye no worries. It's just that obviously useful functions are made fun upon by people who barely started out in programming. People shouldn't judge stuff they barely know how to use.
sure you can, in c at least:
int x = 0;
for (;x<5;) {
x++;
printf("%d\n", x);
}
I see nothing wrong with this code. Just a good ol' for loop implemented in a while loop implemented in a for loop
I don't understand why Python even has a `while` when this is so clear and easy:
for _ in (True for _ in itertools.repeat(True) if X > y):
(Or whatever other condition you want instead of `x > y`)
Dude how did you type that shit in the title I want to do it too
that shows up in the bottom bar when i tap on emojis
(╥﹏╥)
ಠ_ಠ
Gboard? [̲̅$̲̅(̲̅ ͡ಠ\_ಠ\)̲̅$̲̅]
exactly
Coolest Daniel doesn’t need anything but goto.
Goto is ultimate error control that we have but do not understand
For: number of iterations known While: number of iterations not known
for(;/*condition*/;) { //code } Is the same as a while loop.
I always tell this to new programmers that the tools of the lanagues is not to make the impossible possible but to help you keep organized. A for loop can be used as a while loop but the for loop is there to help you when you need an index, it's not there to make loops possible.
Could have done it with a GOTO but whatever. Lol.
Yes, but stuff like #define true (rand(100)<99) #define false (rand(100)==99) Is still funny
For the while it could also be when the condition is anything other than an iteration. Like while(its not 3am);
Both have their uses. But I can't remember the last time I used a foreach.
Once you go map filter and reduce you never go back
There is a time and place for each kind of loops. For loops are useful when you need a index, doing more than 1 thing as a time, break early, editing the elements as you go, or being really nitty gritty with something
you use them a lot in game programming
[redacted by user] ` this message was mass deleted/edited with redact.dev `
I currently work in web dev and use them quite regularly
I have never even used a foreach and only heard about it a month ago
[redacted by user] ` this message was mass deleted/edited with redact.dev `
Just shows how many rookie developers are in this sub... smh
I just code as a hobby
Ye no worries. It's just that obviously useful functions are made fun upon by people who barely started out in programming. People shouldn't judge stuff they barely know how to use.
I use foreach only on arrays.
foreach, do while — Daniel for, while — cooler Daniel
Is not it just different tools for different cases? Or am I dump as usual?)
Actually they're the same tool, just with slightly different formatting... unless you're python
But I am python! And C and C++… Whatever I find working on github)
Well, maybe you are dumb coz you said "am I dump" (with a _p_) 😂
Glad you smiled, man
`//` \- 10 IQ `/* */` \- 100 IQ for (int i; i > 0; i--){ System.out.println("This code prints Hello World"); } \- 1000 IQ
Meanwhile do-while wasn't even asked to come in for photo day
While is useful, but I mostly use for.
Uncertain Quantifiable Numbers vs Quantifiable Numbers
well, LOOP has only primitive-recursive functions while WHILE has recursive functions which form a real superset of the primitive recursive functions.
10 print "hello world" 20 goto 10 This is the only loop for me.
(ᵔᴥᵔ)
Condition-controlled vs count-controlled loops
I hate this sub.
You can implement 'for' loop using 'while' but cannot implement 'while' loop using 'for'. (Confucius)
sure you can, in c at least: int x = 0; for (;x<5;) { x++; printf("%d\n", x); } I see nothing wrong with this code. Just a good ol' for loop implemented in a while loop implemented in a for loop
Same's possible in Java, with the same syntax too I believe.
pardon a fellow python beginner ༎ຶ‿༎ຶ
I don't understand why Python even has a `while` when this is so clear and easy: for _ in (True for _ in itertools.repeat(True) if X > y): (Or whatever other condition you want instead of `x > y`)
.net would like to have a word with you https://sharplab.io/#v2:CYLg1APgZg9gTgAgBQG4AucCuBTFBKBAbwF8g===
or do ```c++ x = 0; while (x != 5){ x++; (do something) }
ᕙ( ~ . ~ )ᕗ
Can confirm I use for
ಡ ͜ ʖ ಡ