Questions tagged as 'loop'

2
answers

Limit of items in the "foreach"

I have a code that takes the images from the images/FotosdoWhatsAPP folder, but it is displaying all the images, I would like to display only a quantity X (eg 5 images). <?php $dirname = "images/FotosWhatsApp/"; $images = glob($dir...
asked by 20.11.2018 / 23:38
2
answers

Performance in Java repetition loops

What a difference of performance between the three types of ties highlighted below. List<Foo> list = new ArrayList<Foo>(); for (int i = 0; i < list.size(); i++) { //CODE } for (Foo foo : list) { //CODE } Iterator<F...
asked by 31.03.2014 / 16:28
2
answers

Increment variable inside a foreach [closed]

How do I make a variable increment within a foreach ? foreach($adults as $adultos): $i = 1; echo "<strong>Quarto".$i++."</strong><br>"; echo "Adultos:".$adultos."<br>"; endforeach;     
asked by 19.09.2017 / 01:51
1
answer

Turn all elements of a list into floats

This is the code I wrote. n_alunos=input('') x=0 idades=[] alturas=[] while x != n_alunos: x+=1 n=raw_input('') a=n.split(" ") idades.append(a[0]) alturas.append(a[1]) How do I transform the elements of the 2 string lis...
asked by 19.11.2017 / 23:27
3
answers

Repeat if again when validation fails

ConvInicial = str(input('Você: ')) if ConvInicial == 'Não estou passando bem' or ConvInicial == 'Estou com dor' or ConvInicial == 'Preciso de ajuda': print('O que você está sentindo?') RespDor = input('Você: ') if RespDor == 'Estou com dor de ca...
asked by 13.10.2018 / 23:02
1
answer

Delphi - Make a Thread that plays a song in loop

I managed to make a Thread that plays the song, but only for 1 time.  If I put a loop in it I have several errors, like the 1400. It seems that the thread does not close when Form1 is closed, because the problem always happens when I try to c...
asked by 02.11.2015 / 19:48
1
answer

Monitoring with the R

I have a tracking script and would like to run it every five minutes, is there any function that does this? For example: função (meu_script, repetir= 5 minutos) I tried some functions with Sys.time() and proc.time() , but I...
asked by 28.02.2018 / 18:12
2
answers

How to get index of an advanced "for"?

I was wondering if I can get some kind of control variable from an "% advanced"%. " For example: On a normal for, I do this as follows: for (int i = 0; i < algumaCoisa.size() ou length; i++){ //código.. } this variable for...
asked by 27.07.2017 / 03:12
2
answers

How do I stop "for" when I find an element in the list?

I have the following code: Console.Clear(); Console.Write("Nome da moto:"); string nomem = Console.ReadLine(); for (int i = 0; i < ListadeVeiculos.Count; i++) { if (nomem == ListadeVeiculos[i].Nomemoto) Console.Write("Preço...
asked by 19.05.2018 / 21:07
2
answers

List in Python with non-repeated values without using set function?

How can I create a list from the sum of two previous ones without some value appearing repeated, without using the set function? Example: >>>a = [1, 2, 3] >>>b = [3, 4, 5] >>>c = a + b >>>print c [...
asked by 19.03.2016 / 03:23