You have several options: 1. Sequential for loop: var myStringArray = ["Hello","World"]; var arrayLength = myStringArray.length; for (var i = 0; i < arrayLength; i++) { console.log(myStringArray[... Read More
First of all, in your example you make tests on a "data.frame" which is not fair for colMeans, apply and "[.data.frame" since they have an overhead: system.time(as.matrix(m)) #called by `colMeans` a... Read More
Biggest problem and root of ineffectiveness is indexing data.frame, I mean all this lines where you use temp[,]. Try to avoid this as much as possible. I took your function, change indexing and here... Read More
From anishsane's answer and the comments therein we now know what you want. Here's the same thing in a bashier style, using a for loop. See the Looping Constructs section in the reference manual. I'm... Read More
scala> 10 to 1 by -1 res1: scala.collection.immutable.Range = Range(10, 9, 8, 7, 6, 5, 4, 3, 2, 1)... Read More
In Python 2.x: range creates a list, so if you do range(1, 10000000) it creates a list in memory with 9999999 elements. xrange is a sequence object that evaluates lazily. In Python 3, range does t... Read More
You can use generator expressions like this: gen = (x for x in xyz if x not in a) for x in gen: print x... Read More
The array is being re-indexed when you do a .splice(), which means you'll skip over an index when one is removed, and your cached .length is obsolete. To fix it, you'd either need to decrement i afte... Read More
users.each_with_index do |u, index| # some code if index == users.size - 1 # code for the last user end end... Read More
The <c:forEach> tag is definitely suitable for this. It has begin and end attributes where you can specify the, well, begin and end. It has a varStatus attribute which puts a LoopTagStatus object in... Read More