I want to generate separate databases in a loop. In the example below there would be 3 distinct bases with the following names: "data1", "data2", "data3".
for (n in 1:3){
dados<-paste0("dados",n)
dados<-runif(10,1,20)}
However, wh...
Let's say I have this for loop that works based on my array name:
var nomes = ["Nome 1", "Nome 2", "Nome 3"];
for(i = 0; i <= 2; i++) {
if(nomes[i] == "Nome 2") {
console.log(nomes[i]);
console.log("Stop!");...
Being a loop while and a for that rotate the same number of times, which is faster? Example:
while :
int i = 0;
int max = 10;
while(i<max){
funcao();
i++;
}
for :
int i;
int max = 10;
for(i=0; i<...
Is there any way for me to do this? While it's one thing to do that, then when is it another to do that?
For example:
var i = 0;
while(i < 5){
//faça isso
i++;
} else {
//faça aquilo
}
Is it possible to do this somehow?
...
In the two ways below, which one performs better?
For :
for( $x=1; $x < 31; $x++ )
echo $x . PHP_EOL;
Foreach + range :
foreach( range(1,30) as $x )
echo $x . PHP_EOL;
I know the difference will proba...
I need this function to be automated so that it applies to all images made on the HTML document without any exception
Code
function aumenta(obj) {
obj.height = obj.height * 2;
obj.width = obj.width * 2;
}
function diminui(...
We can iterate an Array / list in ruby in two ways:
Using the for x in y syntax:
> for x in [1,2,3] do
> puts x
> end
1
2
3
=> [1, 2, 3]
Using the method .each
> [1,2,3].each do |x|
> puts x...
I've learned that in Python , to loop% with for , from 1 to 10, we use range .
More or less like this:
for i in range(1, 10):
print(i)
Generally, in other languages, when we need to do a simple increment, we use the...
Java allows us to concatenate Strings in Java using just the '+' operator
String str = "a" + "b" + "c";
It's a simple way to do the job, and much less verbose than using StringBuilder.
But in cases of Loops like the one below, which appr...
Translate into the C language: Take a number from the keyboard and repeat the operation by multiplying it by three (by printing the new value) until it is greater than 100. Eg if the user types 5, screen the following sequence: 5 15 45 135....