I think the main reason I don't write more is I think once I've thought through something it's too obvious to write down. I consider it a defect of mine and sometimes have to force myself to write.
Here are the particular comments having to do with this (I don't know how to link to an individual post in the discussion...maybe somebody can write that down for me :):
A: There is a vast amount of mathematical knowledge that hasn’t even been written down, much less formalized.
B: There is no such thing as knowledge that has never even been written down a single time by anyone or anything. Those are simply called ideas...
bool w;
int x[1000];
int y[1000];
for(int i=0;i<1000;i++){
x[i] += y[i];
}
if(w){
for(int i=0;i<1000;i++){
y[i] = 0;
}
}
Slower but prettier with the if pushed down.Easier for humans to reason about the branch, when they know that it happens without input from i or y[i].
This is helpful when the `if` statement is complex, or there are multiple if statements, some of which do take y[i] as input.
The machine?
A loop contains a branch - keep looping or break. At least according to structured programming -- https://en.wikipedia.org/wiki/Structured_program_theorem.
interesting question...
> A loop is a chunk of code that will be run N times depending
oh! turns out you do!
for (fn, n) = {
stop = void (i) {}
run = void (i) { fn(i); go(i + 1) }
go = void (i) { *((i < n) * &run + (i >= n) * &stop)(i) }
go(0)
}
Or you could write all the implementations for each possible n and dispatch through a registry.Just a simple example, but the conditional branch occurs on line 14 of the generated assembly. It does a comparison (line 13) and then a conditional jump (jl, line 14).
Anyone who started out programming in assembly languages
The CPU.
Option<Walrus>