10,929 questions
Best practices
0
votes
6
replies
150
views
Iterating a 2D Array Diagonally in Python
I have an array with almost infinite dimensions. I would like to iterate it from top left to bottom right, and when a certain threshold is reached iteration can be stoped.
I create our test array.
mat ...
Advice
0
votes
5
replies
95
views
How to remove items from a list that contain special characters while iterating
Let's say I have a list called words that contains some items with special characters (anything not alphanumerical).
for i in words:
#check if i contains special characters and return True or ...
Score of -1
3 answers
214 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
55
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. ...
Score of -6
2 answers
128 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
214
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 ...
Score of 1
1 answer
211 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 ...
Score of 2
1 answer
173 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
255
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 ...
Score of -6
2 answers
138 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 ...
Score of 3
4 answers
240 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 {
...
Score of 3
2 answers
306 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 ...
Score of -5
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 ...
Score of 1
1 answer
126 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 = ...
Score of 0
2 answers
104 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():...