i think iām understanding for loops ... it is a miracleĀ

#ryland grace#phm#rocky the eridian#project hail mary spoilers



seen from United States

seen from Australia

seen from France
seen from United States

seen from United States

seen from United States

seen from France

seen from Germany

seen from China
seen from China
seen from Sweden
seen from United States
seen from United States

seen from Germany

seen from Malaysia

seen from United States

seen from France
seen from United States

seen from Namibia
seen from Poland
i think iām understanding for loops ... it is a miracleĀ
weāre learning for loops now.... thanks, i hate itĀ
Loops play a very important part in our Lives. Whenever we need to play over large sets of Data, we usually use For Loops. But have you ever made a thought how the way you write your For Loop affects your CPU Time? Nope!!!! Okay Let me give you an overview on that.
#freecodecampĀ āIterate with #JavaScript For Loops
forloops replied to your post:Iām at the airport, and thereās a guy here waiting...
If Logan doesnāt have a puppy with him when he comes to pick me up on Saturday, weāre done.
Not just a regular puppy, though. One that stand up and smiles creepily, preferably with a huge head.
Three Tips to Help Optimize Your Code.
This may not boost your program's speed tenfold (in fact, some compilers out there already take care of a lot of optimization behind the scenes), but I'm a firm believer in the idea that every bit counts and that knowledge is power. So, without further ado, here are a few tips that may be more or less relevant to my fellow novice programmers: Code Motion ("Precomputation") This is a fairly simple thing to catch. For a simple example, let's say you have a for-loop that reads: for (int i = 0; i < someString.length(); i++) Every time your program runs that loop, it will call someString.length(). The easy solution to this is to define the length just before the loop and store it in a variable: int len = someString.length(); for (int i = 0; i < len; i++) And just like that, you only call someString.length() once! On modern day hardware, this doesn't always make a huge difference (unless you have a humongous string), but for more intensive algorithms - or if the loop happens to be called a lot - there will be a noticeable difference in your program's speed. Share Common Subexpressions Let's say you have a few variables being computed: int i = (q * p) + 1; int j = (q * p) + 2; int k = (q * p) + 3; // etc... Now, it may seem messy to want to add another variable on that list, but it improves program performance if you assign (q * p) to a variable beforehand, so your code reads more like this: int qp = (q * p); int i = qp + 1; int j = qp + 2; int k = qp + 3; // etc... And just like that, you've improved your program's performance. Know Your Language - Row Major or Column Major? This tends to make a big difference if you're working with nested loops and a data structure such as a 2D array. If I said to imagine drawing out a picture of a 2D array, you would imagine it would have n columns and m rows, right? But on computers, a 2D array isn't stored as a rectangle in memory - it's stored as a continuous row of data. Depending on your language, it may store this data with the rows as one giant row (row-major - languages such as C++ and Java), or the columns as one giant row (column-major - languages such as FORTRAN and MATLAB). To illustrate, if we have a 2x2 2D array: a Ā b c Ā d This would then be stored as: Row major: a b c d Column major: a c b d Let's say we're working in C (because we're masochists and like low-level languages), which is row-major. If we have a loop such as: // Psuedo-code given a 2D array, arr from i = 0 to 2048 Ā Ā from j = 0 to 2048 Ā Ā Ā Ā arr[i][j] = (i + 1) * (j + 2) This will run noticeably faster than: // j-loop first, then i-loop from j = 0 to 2048 Ā Ā from i = 0 to 2048 Ā Ā Ā Ā arr[i][j] = (i + 1) * (j + 2) And vice-versa for column-major languages. I know this was a long point to illustrate, and it may seem a little jumbled, but it's not too bad - I promise (you may have even worked with nested loops this way prior discovering this). So, with that, hopefully this will help some of you guys looking to fine-tune your code. There are many more ways to optimize your program than this, but I hope the points I discussed are something you can remember and, with any luck, turn into a habit. Happy coding!
Small Optimization Tweak When Writing JavaScript for Loops
So today I was tooling around with this dynamic object generator that writes object blocks to an HTML5 canvas and even checks for object collision so that things are evenly spaced. Well, while doing this, and with hours and hours of Googling, I was able to find a much more sufficient way to write for loops. Its the small things in life that keep the world turning... as someone may say...
Here is what I am talking about:
Normal For Loop
var arr = []; arr[0] = 1; arr[1] = 2; arr[2] = 3; for(i = 0; i < arr.length; i++) { console.log(arr[i]) }
The piece that is not optimal is when you write
i < arr.length
... essentially you are having to check for the array length EVERY time you iterate over the items in the array.
To avoid this, simply store your array length in a variable...
var arr = []; arr[0] = 1; arr[1] = 2; arr[2] = 3; var len = arr.length; for(i = 0; i < len; i++) { console.log(arr[i]) }
And small items like that will help you write faster JS that the browser won't have trouble interpreting.
Happy JavaScripting!