
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
The main task is to clear the array of defined values.
This cannot be the main task. What is collected in this array and how is it then used?
Well that's not serious. If pulling elephants to solve this particular small problem, I'd mention STL::remove(array, value).
That's just very serious and fundamental. MQL is just verbose. Terribly so.
Fundamental operators such as filter (which in TC is it, filtering), map (mapping), fold (collapsing, summarizing)
should be implemented at once, no questions asked. And be optimized.
This is just very serious and fundamental. MQL is just verbose. It's horrible.
Such fundamental operators as filter (which in TC is filtering), map (mapping), fold (summation)
should be implemented at once, without any questions. And be optimised.
The point is that pulling such a fat ("fundamental") dependency for a small task is nonsense. If to write everything wisely and refactor the whole project - then, of course, but it is not the essence of the original question.
Forum on trading, automated trading systems and trading strategy testing
Cleaning an Array from Specified Elements
Dmitry Fedoseev, 2018.11.12 23:05
This is some kind of shame...©
1. Comparing variables of type double via ==, to put it mildly, is not comical;
2. The code's complexity is O(n^2), and the worst complexity for this problem with an unsorted input sequence should be O(n);
3. The code does not work, because when the function is actually used, it is impossible to determine how many valid values the returned array contains:
Execution result:
The invalid values are highlighted in red, they were never removed from the array.
This is some kind of shame...©
1. It's not nice to compare variables of the double type via ==, to put it mildly;
2. The code complexity is O(n^2), and the worst-case complexity for this problem with an unsorted input sequence should be O(n);
3. The code does not work, because when the function is actually used, it is impossible to determine how many valid values the returned array contains:
Execution result:
Invalid values that were never removed from the array are highlighted in red.
Jublik? So be it. Comparing variables of the double type is quite comical if they are not calculated before comparing.
Learn the math. What about shame?
This is some kind of shame...©
1. Comparing variables of type double with == is, to put it mildly, not comical;
2. The code complexity is O(n^2), and the worst complexity for this problem with unsorted input sequence should be O(n);
3. The code does not work, because when the function is actually used, it is impossible to determine how many valid values the returned array contains:
Execution result:
Invalid values that were never removed from the array are highlighted in red.
Don't be absurd. Shall I explain your mistake to you, or can you guess it yourself? Not difficult at all...
Three points, three corrals. Actually, no, only two paddocks.
ps, but I have faith in you.
ps2 here's the result if you use the function correctly:
That's better:
That's better:
Dimitri, let me upset you - v is also an array.
And anyway, it's all a load of nonsense.
Dimitri, let me upset you - v is also an array.
And in general, all this is total nonsense.
If v is an array, it's not a problem. But the fact that it is nonsense is more likely. I've never felt the need to solve this task.
If it's such a speed contest, I'll offer my own variant as well:
I wrote a test script for all variants.
Who's next? :))Here's the result for an array of 1 000 000 elements (about 1000 extra values):
Peter, Awww....