As seen above, the algorithm uses "do" after "For". I am aware this is only a pseudo-algorithm but is this theoretically okay?
I am not willing to share the entire algorithm as it is not my work.
As seen above, the algorithm uses "do" after "For". I am aware this is only a pseudo-algorithm but is this theoretically okay?
I am not willing to share the entire algorithm as it is not my work.
In code like that "do" is just a word meaning "do the stuff listed right below here". Some programming languages have a do
keyword, like Bash or Ruby, while many don't.
In Python:
for e in edges:
# ...
In C++:
for (auto&& e : edges) {
// ...
}
Neither of them uses do
.
For contrast, Ruby uses do
to define blocks, akin to function(e) { ... }
in JavaScript:
edges.each do |e|
# ...
end
And Bash where it's a necessary element of the loop:
for edge in $(edges); do
# ...
done
The notation you're seeing there is just a convention used quite often in computer science, but it's basically just an English explanation.
I think that in this mathematical algorithm the "do" does not mean the same as in the syntax of a programming language.
In C++ this "do" will be not the do { /* ... */ } while ()
construct, but simply the brackets after the for: for (/* edges e_wi */) { /* algorithm */ }
.
That is, "do" in mathematics is just a syntactical construct that means "this is the body". So, you can't use "do" after a "for" loop.