Clearing an array of defined element(s) - page 7

 
Sergey Dzyublik:

What's there to talk about?

Perhaps, how is it even more refined to smear the forum with shitcod.

ahahaha ))) he wasn't even too lazy to write it

 
Maxim Dmitrievsky:

ahahahah ))) he wasn't too lazy to write it, either.

Of course he was. I need a laugh too. :)))

 
Реter Konow:

Of course I'm not lazy. I need a laugh, too. :)))

ArrayPrint()

 
Maxim Dmitrievsky:

ArrayPrint()

I didn't know that!!!))

 
OK, that's a joke. The solution seems to be very quick. There might be some weaknesses in it.
 
Реter Konow:

Do you have a faster solution?

Go through the loop and collect the result via concatenation in string?
And if you're not too lazy, you can do it that way (as it turns out, MT4 doesn't have ArrayPrint function):


void OnStart(){
   double arr[] = {1, 2 ,3 ,4.5, 5};
   string res = ArrayFormat(arr, "%f", "   -    ");
   Print(res);
}

template<typename T>
string ArrayFormat(T &arr[], string format = "%016llX", string delimeter = ", "){
   string result;
   for (int i = 0; i < ArraySize(arr); i++){
      result += StringFormat(format, arr[i]) + delimeter;
   }
   result = StringSubstr(result, 0, StringLen(result) - StringLen(delimeter));
   return result;
}

Result:
2018.11.13 14:13:44.267 Test EURUSD,H1: 1.000000   -    2.000000   -    3.000000   -    4.500000   -    5.000000
 
Nikolai Semko:

Well, if it's such a speed contest, I'll offer my own version:

Wrote a test script for all variants.
Here is the result for an array of 1 000 000 elements (about 1000 extra values):

Who's next? :))
Peter, Awww....
Please, someone paste Peter's code here:
https://www.mql5.com/ru/forum/289594/page3#comment_9340812
I'd really like to see how Pyotr did it. I'm just not at the computer myself at the moment.
 
Nikolai Semko:
Please, someone put Peter's code in here:
https://www.mql5.com/ru/forum/289594/page3#comment_9340812
Because I really want to see how Peter did it. I'm just not on the computer myself at the moment.

Nikolai, I didn't set out to beat everyone. I just came up with my own solution. Then I looked at the previous pages and saw that there was a kind of competition. So, the goal to beat anyone or anything wasn't. It's just that all the time there are people who want to beat me. I have to respond in kind.

 
Реter Konow:

Nikolai, I didn't set out to beat everyone. I just came up with my own solution. Then I looked at the previous pages and saw that there was some sort of competition. So, the goal was not to beat anyone or anything. It's just that all the time there are people who want to beat me. I have to respond in the same way.

Yeah, well...
I figured as much :)
 
A man is not a reader,a man is awriter.©