10,930 questions
-1
votes
3
answers
194
views
Can I iterate over/get an iterable over multiple promises by order of their settlement? [duplicate]
In my code, I have a bunch of asynchronous tasks, which will be represented as Promises. Say, let those be:
let promises = myarr.map( (x) => myAsyncFn(x) );
I want to trigger some action after ...
Best practices
0
votes
2
replies
52
views
How to use r to iterate through a list to find where the item appeared previously, then find a value in that row
I am new to r and am having a hard time figuring out how to use r to find a specific item, then report back a value from that same row. The same 40 items appear in two columns, but in a random order. ...
-6
votes
2
answers
121
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 ...
Advice
0
votes
8
replies
202
views
Finding the max values for list values for each key in a dictionary without using max()
Let's say I have a dictionary such as:
dict = { "Mars": [4, 3, 4, 7, 10], "Jupiter": [6, 6, 7, 9, 11], "Saturn": [4, 5, 12, 22, 1]}
I would like to iterate through each ...
1
vote
1
answer
164
views
Calculations from Timestamp based on Checkbox Iterative now() in Google Sheets
I don't want to use Google Apps Scripts, just formulas so that this can be display/edited on a mobile device while offline.
[![In column B, I want to put timestamps when a checkbox in Column D becomes ...
2
votes
1
answer
165
views
Concatenate Tables Based on Column Information in Python [duplicate]
I have a dataframes pulled from a file. The variable with all these dataframe names is: Data_Tables.
These dataframes all have the same columns, and I want to concatenate the dataframes based on the ...
Best practices
1
vote
7
replies
220
views
How to best group an iterator's items into batches?
Our program reads results of an SQL query and turns each row into a task for a worker to perform. Something like:
for row in query.results():
cluster.submit(row)
However, most of the tasks are so ...
-6
votes
2
answers
135
views
Why does list iterator skip elements after in-place modification using slice assignment
I know that modifying a list while iterating over it is dangerous. For example, using my_list.remove() is a famous problem because it causes the iterator to skip the next element.
However, I found a ...
3
votes
4
answers
234
views
Is there an alternative to `all` that returns Result instead of bool?
Consider an example where one needs to iterate over a sequence with all but the output yes/no requires unwrapping somehow.
pub fn interesting(i : u32) -> Result<bool, ()> {
if i < 42 {
...
3
votes
2
answers
293
views
Is iteration order of a set in Python preserved until that set is modified?
According to the Python documentation, set is a mutable unordered collection.
Usually, it's implemented as a hash table that stores references to objects as its keys. Comparing to dict (which is also ...
-5
votes
1
answer
152
views
calling a class object in an iterative way on python
I made the next class
obj = MyClass()
fds=['a','b','c']
for i in fds:
attribute_name = f"{i}"
setattr(obj, attribute_name, [f"{i}"])
print(obj.i)
I know that obj.i is ...
1
vote
1
answer
122
views
takeWhile equivalent for Kotlin maps
My Kotlin project needs to parse files and keep track of the outcome:
fun parseFiles(dp:MyDataProvider, files:List<String>)
{
//store the status of each processed file
val statusMap = ...
0
votes
2
answers
98
views
python basics: can someone help me understand processing one file vs processing all files at a time?
This will output all csv files from the directory, but only show one of the csv dataframes.
OUTPUT_PATH = "./static/output/"
FILE_LIST = glob.glob("./static/*.json")
def all_data():...
1
vote
1
answer
85
views
Conditional iteration with snakemake and checkpoint
Issue
For my workflow I need to repeat a certain number of rules multiple times, the idea is that with each of these iteration the output gets better and better.
I had issue with adding new jobs to ...
3
votes
1
answer
171
views
Weirdness with foreach() iteration of array data [duplicate]
I have a csv file on the webserver (eg. 5GDPR6LR-1.csv)
The csv file consists of data from an associative array written to file using fputcsv() within a foreach() loop.
The problem occurs when I try ...