![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I don't know...
In my opinion, both such "empty" blocks and "infinite loops" (whether for or while) are a bad programming style, dangerous for potentially hard-to-calculate errors.
The loop's condition check operator should not be meaningless but bear some burden. If we have an "infinite loop", it means that there are some additional outputs and breaks inside the loop and they are not always obvious. By the way, I don't like break operator either - I always use continue operator in a loop.
And as was said here code obfuscation is just childish... Great programmers-copyists gathered here who are afraid that someone will sell their code or get millions of dollars in other ways... Pride is one of the deadly sins!
do not agree.
Try rewriting this code without the infinite loop and break
don't agree.
Try to rewrite this code without the infinite loop and break
An interesting task.
In my opinion, the presented code is rather "opaque" and difficult to understand, although the structure is clear to me, and the function is useful.
At first sight, the loop should be while (i<size) {....}, but I haven't understood it thoroughly yet.
As soon as I get my hands on it, I'll get to it.
An interesting task.
In my opinion, the presented code is rather "opaque" and difficult to understand, although the structure is clear to me and the function is useful.
At first glance, the loop should be while (i<size) {....}, but I have not thoroughly understood it yet.
As soon as I get around to it, I'll get to it.
The function removes all val values from array a[] and compacts it, removing "holes" from deleted elements without changing the data sequence.
The function deletes all val values from the array a[] and compacts it, removing "holes" from the deleted elements without changing the data sequence.
Yes, yes, I told you - the purpose is clear, the function itself is useful. Now I can't yet, later I'll figure out how it works, and I'll rewrite it without infinite loop. Well, and then - I will write my variant of function, as I would write.
Yes, yes, I told you - the purpose is clear, the function itself is useful. Now I can't yet, later I will sort out my work and rewrite it without infinite loop. Well, and then - I'll write my version of the function, as I would write it.
the code was taken from here. There was a spontaneous competition a year and a half ago.
do not agree.
Try rewriting this code without the infinite loop and break
Yes it is clear that there are more compact variants, but slower.
Your variant is 2-3 times slower than above and there is an error somewhere, because it gives wrong checksum.
We are talking about the fastest option without HashSet.
I don't know...
In my opinion, both such "empty" blocks and "infinite loops" (whether for or while) are a bad programming style, dangerous for potentially hard-to-calculate errors.
The loop's condition check operator should not be meaningless but bear some burden. If we have an "infinite loop", it means that there are some additional outputs and breaks inside the loop and they are not always obvious. By the way, I don't like break operator either - I always use continue operator in a loop.
And as was said here code obfuscation is just childish... Great programmers-copyists gathered here who are afraid that someone will sell their code or get millions of dollars in other ways... Pride is one of the deadly sins!
Maxim, it doesn't work that way, there should be 2 cycles, otherwise there is no way. First you remove unnecessary elements, then you "shrink" the array upwards (float). The second loop is inside the first one.
A for construct involves checking a condition and exiting before the cycle starts.
A while construct involves checking a condition and exiting before the loop ends.
An infinite loop implies checking the condition and exiting at any point in the loop.