96,574 questions
0
votes
0
answers
97
views
Foreach loop on a multi-dimensional PHP array returns complete wrong results [duplicate]
I have a fairly straightforward MYSQL query which retrieves details from a sale and stores them in an array (I've simplified it by just using 1 saleid which has only 1 salesdetails row - other sales ...
0
votes
1
answer
67
views
Does jit compiler parallelize list comprehension with independent statements in `jax`
I need to apply a jax function to a sequence of arrays of varying sizes. For example:
import jax.numpy as jnp
arrs = [jnp.array([1., 2.]),
jnp.array([6., 7., 8.]),
jnp.array([12.])]
...
Advice
1
vote
6
replies
182
views
Why does removing elements from a list in a for loop in Python skip values?
I'm new to Python and I'm trying to write a script that removes all even numbers from a list. My logic was to loop through the list and, if a number is divisible by 2, remove it.
Here is my code:
...
Advice
1
vote
4
replies
71
views
R - Assign grouping variable for each row based on calculation between rows
I am wanting to assign a group indicator to my data based on the difference between a value of a field in the row and the value in the same field in the previous row. I think data.table's shift() ...
3
votes
1
answer
94
views
2D fourier transform gone wrong ,where am I wrong?
I used to do audio sampling but now I have moved into images.I am trying to implement the discrete fourier transform for a image(16x16 bits).
I have created my own image decoder.Every file contains ...
-6
votes
2
answers
120
views
How can I get Javascript to run through a list of predefined responses, in order? [closed]
I'm trying to create a setup where a user can talk to a chatbot, and the chatbot will run through a predetermined list of responses in consecutive order. The bot will respond each time the user gives ...
0
votes
2
answers
114
views
Delete rows from a global array passed between several subs
I have a global variable FlowTable() as Variant. I delete rows in it within a loop. Each time it runs, it should update the Ubound(FlowTable) because one row will have been deleted.
I tried to enforce ...
1
vote
1
answer
60
views
Selenium nested for loop iteration in iteration over urls [closed]
I am trying to iterate through a list of Urls find some elements, one of which is a list of other Urls.
I then want to, in the same overarching loop iterate through the second list of Urls and find a ...
1
vote
1
answer
118
views
C console program not producing correct output [closed]
I am trying to recreate YSAP Terminal Christmas Tree in C instead of in Bash. I know there's a bunch of weird code as I don't do a lot of C programming, so a lot of it is mashed together from what I ...
1
vote
2
answers
95
views
How can I run multiple separate loops independently from one another in Arduino IDE?
I'm trying to make 3 LEDs (a red, a green, and a blue) flash simultaneously. The blue one should flash slowly, the green one should go quicker, and the red should be fastest. I tried putting multiple ...
0
votes
2
answers
85
views
Gnuplot 2D histograms bins in loop
This is a follow up to a similar question Plot with 2D histograms bins answered by @theozh. I've been trying to modify the linked code to work in a loop. However I've encountered a few problems ...
-2
votes
3
answers
94
views
Click event works only for first element in loop in a Django template [duplicate]
I am looping around a cart dictionary that is in the session and I have defined a product for all the items. When each cart item button is clicked, they are sent via ajax, but only the first item is ...
1
vote
2
answers
85
views
Why doesn't sh's continue remember the command's exit status
Why doesn't continue remember the command's exit status in sh?
Given this loop:
#!/bin/sh
for i in 0; do
false || continue
done
echo $?
Output: 0
#!/bin/sh
for i in 0; do
false
done
echo $?
...
Best practices
0
votes
4
replies
135
views
Best method to loop a list while removing items
I have a list of ranges that consist of a start and end value. I need to optimise the list by identifying any overlapping ranges and merging them so that there is no duplication on the list.
I have ...
6
votes
4
answers
243
views
awk command to subtract constant from a column and print results
I was working on a one-liner to subtract a constant value (e.g. 100 in this case) from a specific column using awk. So far I can manage to get to where I can print the last iteration only – which ...