Re: Function v. Writing operations
I understand all the fallacies of this question, but... Well, I was a little curious to see what would happen if I made some deductions about the purpose of the question did try to benchmark the following: j = 0 benchmark "function": for i in countup(1, x): inc j vs j = 0 benchmark "operator": for i in 1..x: j = j + 1 The following code is only for without compiler optimization and on platforms that support [rdtsc](https://en.wikipedia.org/wiki/Time_Stamp_Counter): [https://gist.github.com/lbmn/d424dd0c8c85fa195743356fc133235a](https://gist.github.com/lbmn/d424dd0c8c85fa195743356fc133235a) So now there's a new way to flip a coin!
Re: Function v. Writing operations
@jibal No, I agree with planhths, that was likely our forum troll and so I banned him.
Re: Function v. Writing operations
@planhths Hanlon's Razor
Re: Function v. Writing operations
Well the performance bottleneck is obviously the echo statement.
Re: Function v. Writing operations
Omg and you wanted to write a book? Nice trolling bro.
Re: Function v. Writing operations
Looking at the docs [here](https://nim-lang.org/docs/system.html#14) , `..` is an alias for `countup`. btw, this for i in ..10: echo i works.
Re: Function v. Writing operations
Both samples are incorrect, they both don't compile. Here are the correct samples: for i in countup(1, 10): echo i for i in 1..10: echo i As to performance, running both programs 100 times took about 800 milliseconds. They are virtually the same, to no surprise.
Re: Function v. Writing operations
That doesn't really make sense. The for loop itself increments the variable. You can't increment it because it is immutable. And you need a colon and a lower bound.
Re: Function v. Writing operations
Benchmark it and you'll find out.