Nothing like O(N^2) algorithms to start the morning.
Unless I can dispatch the inner loop to a thread, I usually try to get rid of nested loops.
“i” is the only acceptable single letter loop index variable.
Good morning btw. 🤣
Nothing like O(N^2) algorithms to start the morning.
Unless I can dispatch the inner loop to a thread, I usually try to get rid of nested loops.
“i” is the only acceptable single letter loop index variable.
Good morning btw. 🤣
Oh and languages without decent for-each loops are garbage. 😛
like range clauses? yeah, i can't live without those, if you look at most go code the most common two uses for for loops are iterating arrays/maps and forever loops for event handlers with signal channels to break out, or timeouts
I’m not super familiar with ranges as I don’t program in any languages that lean into it. I can give a C# example though.
Say I have a list of strings (List
foreach (var coworker in myCoworkers)
{
Console.WriteLine(coworker);
}
Does that make sense? No need for an index.
PHP is like
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
$value = $value * 2;
}
Honestly I’m falling in love with PHP. I might cheat on Blazor with it for a while.
its array handling syntax is nice, i also really liked it back in the day... 2003... though its competitor was ASP/VBScript which was ugly as sin
Good morning!
What a way to bring up my "deeply nested-for loops with an if statement in the center nightmare" 🫥
i needed a printout every so often, but i didn't want to print millions of times
```
if iteration % record_every == 0:
record_array.push(fit)
```
Without if statements, its just two for loops.
```
for j in record_every:
iterate(dt)
record_array.push(fit)
```
gm ser 🥲🫡