25,772 questions
0
votes
2
answers
127
views
Why does modifying a List<T> inside a foreach loop throw an exception in C#? [duplicate]
I am iterating over a List<int> in C# and attempting to remove elements based on a condition.
var numbers = new List<int> { 1, 2, 3, 4, 5 };
foreach (var n in numbers)
{
if (n % 2 == ...
Advice
0
votes
7
replies
160
views
C Preprocessor: foreach/macro expansion with loop context
So I've been using this code for generating such statements following This Reddit post:
#define LOOP(seq) END(A seq)
#define BODY(x) int x;
#define A(x) BODY(x) B
#define B(x) BODY(x) A
#define A_END
#...
Best practices
0
votes
2
replies
129
views
Looping Datasets in R
Essentially I am trying to create a dataset that is dependent on prior rows to generate values for any given row. I then would like to run this loop over many IDs for an entire dataset. Current set up ...
Best practices
1
vote
6
replies
96
views
How to get the matching control out of the foreach loop?
In a user control class, I have this code to react to button clicks. The code shall match the tag of a toggle button with the identical tag of another user control, so the button could switch the ...
0
votes
1
answer
90
views
Apache Spark TransformWithState operator not working as expected
Hi I'm trying to implement a stateprocessor for my custom logic., ideally we are streaming and I want the custom logic of calculating packet loss from a previous row.
i implemented the stateprocessor ...
1
vote
3
answers
264
views
Loop to check all cells in a column to send email
I want to check all cells in a column for a value to send an email.
I created the If check.
How do I make it go through a loop to check all cells in the column?
This is the VBA code I made but I can ...
0
votes
1
answer
89
views
ADF Web activity fails within a ForEach activity while it works fine outside of it
I am building an ADF pipeline that uses a ForEach activity to iterate over a bunch of sites. The HTTP endpoint is generated dynamically by use of a @concat expression & fed into the HTTP activity ...
1
vote
1
answer
232
views
How to use a "Loop limit" symbol in a flowchart representing a simple R "for loop"
I know that a simple R "for" loop like the following:
n <- 20
for (i in 1:n) {
print(i)
}
can be represented by a flowchart like:
However, in any set of flowchart symbols there is the ...
1
vote
2
answers
129
views
How to remember change of values in between for-each loops
I am writing a program, that will divide my students into groups. Lets say the groups are A, B, C and D. In each group there can be only so many students. Those numbers I have in a global variable:
&...
3
votes
1
answer
162
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 ...
1
vote
2
answers
75
views
A dead loop problem in JavaScript about Set
Why the following code caused dead loop?
const s = new Set([1]);
s.forEach(e => {
s.delete(e)
s.add(e)
})
I tried to change the order about delete and add operation,the dead loop ...
0
votes
1
answer
94
views
How to use for each item inside copy activity source SQL query in ADF
I’m working in Azure Data Factory. I have a Lookup activity that gets a list of authors from a SQL table. Then, in a ForEach loop, I want to run a Copy activity for each author to fetch only that ...
1
vote
1
answer
72
views
XSLT for-each with using last and aggregation
I am not sure if this is possible with XSLT but I am trying to get the below XML into a format where it is name, title, date (if same date then only get date once), last value of In time (might not be ...
-3
votes
1
answer
72
views
Integrate counter in forEach loop using SwiftUI [closed]
I am trying to code a leaderboard in SwiftUI. The data comes from an array of ranked users so that I should be able to get the rank from the index of the array, but I'm finding it surprisingly ...
1
vote
1
answer
69
views
R foreach %dopar% on R6 class
I have the following multiprocessing code using R6 class.
library(R6)
library(doParallel)
registerDoParallel(cores = 4)
# https://github.com/r-lib/R6/issues/141
a1 <- 2
C1 <- R6Class(
public ...
0
votes
1
answer
107
views
C2664 Compilation Error with Nested std::for_each and Lambda Functions [duplicate]
std::vector<std::vector<bool>> grid(4, std::vector<bool>(4, true));
std::for_each(grid.begin(), grid.end(), [](auto& row) {
std::for_each(row.begin(), row.end(), [](auto& ...
0
votes
0
answers
50
views
Problem with foreach(). Why my simulation function works outside foreach()?
I have a 300-line script that defines the function sim(pars, n.sim).
The problem is in my attempt to use more than one core of my laptop.
I run my simulation, wrapping the right parameters like this:
...
0
votes
0
answers
75
views
How to access a package loaded with devtools::load_all() when using foreach?
I'm working on an R package 'mypkg' and use devtools::load_all() inside an Rstudio project to simulate what loading it would look like after making changes. This works fine for all my code except for ...
0
votes
1
answer
70
views
How do I copy a specific file to have it replace all files of only a specific file type in all subfolders of a directory that match a wildcard in PATH [closed]
So, I'm currently working on a mod for a game, and I might end up having to do this for other mods in the future, so I'd like to know if there is a way to do it with the FOR/DO command in Windows' ...
0
votes
2
answers
129
views
Terraform for_each without support of dynamic block
I am trying to write come terraform code that will take a nested object and create resources, normally this would be done with the dynamic block but the resouce in question doesn't support this, and ...
1
vote
1
answer
86
views
ForEach is used ambiguous
I have the following code:
import SwiftUI
func TableColumnView<T>(title: String? = nil, k : KeyPath<T, Int>) -> some TableColumnContent<T, KeyPathComparator<T>> where T:...
-2
votes
1
answer
84
views
Java Iterator Views
I frequently would like to iterate over a view of some underlying data structure, e.g. a backwards iteration or only a slice of a list. The Java standard library has some support for multiple iterator ...
0
votes
1
answer
35
views
Synchronize printing within Makefile foreach
I have the following example:
LIST_JOB = job1 job2 job3
define macro
$(info "JOB: $(1)")
job_$(1): job.f90
ifort -c job.f90
$(shell touch job.f90)
endef
all: rule
rule: $(foreach ...
0
votes
2
answers
71
views
Export to CSV for each folder in a directory
I am brand new to PowerShell and have gone through tutorials to learn the basics. I'm now at the point where it's a step beyond my knowledge and could use some guidance.
Scenario:
I have a Projects ...
1
vote
1
answer
78
views
continuing past an RPC unavailable error when reaching remote computers in a foreach loop
Wanted to ask what the ideal or best approach is to continuing past an RPC unavailable error when trying to loop through a list of remote machines.
I don't need to fix anything about it, just skip to ...
1
vote
1
answer
46
views
PowerShell - Change items in an array
Correct me if I'm wrong, but shouldn't the below change each element in the array $List to 'ZZZ'?
> $List = @('a','b')
> ForEach($i In $List) { $i = 'ZZZ' }
> $List
a
b
0
votes
1
answer
97
views
Moving result within PHP while loop up one line?
The following code is simple and works when trying to compare previous values from one column to the next. The only problem is that it is displayed one row below where I want. So the numbers do not ...
0
votes
0
answers
59
views
Using CloudFormation ForEach to create list of indefinite size
I want a CloudFormation template to be able to create a list of repositories in a role's Trust relationship, to look like this:
Effect": "Allow",
"Principal": { "...
0
votes
1
answer
41
views
How to mock sftp list in munit with payload and attributes accessible inside foreach after list operation
Mock the sftp-list operation especially the attributes with file name and its path. These attributes are used in a for each loop are not available.
0
votes
1
answer
50
views
bash script loop behavior Issue [duplicate]
in a bash script, I want to get some values as an array, and loop on each value, but the problem when I loop on the values, only one value get read in the logic, while other values disappeared.
list=()...
0
votes
0
answers
38
views
Can one receive simultaneous progress updates from a `doFuture` multisession using `progressr`
I have a slow running function that I execute in multiple settings in parallel using doFuture together with foreach. I would like to receive regular progress updates from each execution using ...
3
votes
2
answers
239
views
Powershell: Issue with foreach loop. "Cannot convert the value of type "System.String" to type "System.Management.Automation.SwitchParameter"
I have a report that I have automated. the report is a CSV file, and it is split every 80,000 lines, so I regularly end up with reports in multiple parts. I have a large function that processes the ...
0
votes
1
answer
31
views
Automatic increment of array's internal pointer and foreach loop in PHP; where to find the implementation [duplicate]
The official documentation says that "Note that foreach does not modify the internal array pointer", but on some books I found this:
Maybe both sentences are right because the internal ...
1
vote
2
answers
83
views
How to change the navbar's color on request?
I want to change the navbar color when my specific div is hitting the top of the page. It only does it on my second request and not on my first, even though the console says it is working.
I can't ...
0
votes
0
answers
26
views
If I pass a NodeListOf<HTMLElement> to the Motion's InView function, is an Intersection Observer created for each Element or is a general one created?
I am working with Motion's InView function to detect different elements within the ViewPort, so I am currently giving it a NodeListOf.
When I do this, it creates a general Intersection Observer, one ...
0
votes
0
answers
67
views
How to set up parallel computing with progress bar using the doParabar package in R
I'm having some difficulty setting up parallel computing with a progress bar in R. I tried using the doSNOW package following the solution here, but no progress bar appeared. The code also took over ...
0
votes
0
answers
50
views
parallel foreach in R is not faster with more cores on an AWS EC2 server
I have to run a simulation study for a model we developed in my phd. I have 64 simulation settings consisting of combinations of different parameters and sample sizes (1000 or 10,000), and I want to ...
1
vote
1
answer
93
views
How to show the diff in all files having leftover conflict marker?
I know git diff --check will list all files having leftover conflict marker, but it doesn't actually show the diff. I think the command to show the diff in all files having leftover conflict marker ...
0
votes
0
answers
109
views
Running a Rcpp function in parallel is slower than running it in serial
I am developping a R function than used a function code in Rcpp (i am already new to this).
I wanted to make simulations and run the same r functions in a cluster of x cores. Unfortunately when I do ...
1
vote
0
answers
57
views
Pause and resume GAM processing in R with multithreading using foreach
I have quite complicated additive models (GAMs) to be processed in R. Since it already takes several days (not finished yet) for even one model, and I would like to process some 100s, I would like to ...
0
votes
0
answers
22
views
R parallel loop foreach never ends in Linux Fedora 39
The code bellow executes in parallel the function "mhrcmx_dep_rep_int" (written in c++) of my R package "mhrcmxIntDepL":
### paths
path = paste0(fs::path_home(),'/rcpedroso/CAI/'); ...
0
votes
1
answer
76
views
Big Matrix not available to workers
I am converting a large data frame into a big.matrix object to enable parallel processing (otherwise, the data frame is too large and I run out of RAM). My code is currently like this:
df <- data....
2
votes
1
answer
1k
views
How to force a EXE Powershell Script compiled with Win-PS2EXE to run with Powershell 7
I have a PowerShell script that I converted to an EXE with Win-PS2EXE.The problem is that I'm using Foreach -parallel and it doesn't work with PowerShell 5.0, I need this EXE to run with the latest ...
1
vote
0
answers
61
views
While using a for-each loop in Java with toCharArray, does it call toCharArray with every iteration? [duplicate]
String test = "123456789";
for(char c: test.toCharArray()) {
System.out.println(c);
}
My question here is: does test.toCharArray() get called everytime during the iteration i.e. in here ...
0
votes
2
answers
151
views
How do I use offset within a forEach loop in google apps script
I have a range consisting of a variable number of rows and 4 columns (A,B,C,D). I need to loop through each of the rows and add the number in column D to the number in column C and then clear the ...
0
votes
2
answers
64
views
Not able to remove nested array element in array
In the below the screen shot , mentioned nested element as child array.
I wanted to remove child array element , I used below the script but it's only remove first element.
removeChildWidget(parIndex:...
1
vote
1
answer
158
views
Subtle difference between for loop and for_each
I've been coding in Rust for some time but I am often caught off-guard by these nuances.
For example, this works:
use std::thread::JoinHandle;
fn main() {
let all_threads: Vec<JoinHandle<()&...
0
votes
1
answer
334
views
Issue with Variable Assignments in Parallel ForEach Loop in Azure Data Factory for Incremental Load
I have variables declared inside a ForEach loop in Azure Data Factory, and they are being assigned sequentially. The values stored in these variables are used for incremental loading, specifically to ...
0
votes
1
answer
36
views
NavigationList ForEach loop from data model
I am having issue with looping through my API call decoded JSON data within a navigation list. I have successfully put the data into a variable and just can't seem to work out how to loop through the ...
-1
votes
1
answer
71
views
How to improve xml parsing performance [closed]
I have a large xml which contain many records as child elements. There are many test elements and inside each test element many testchild elements. There are around 200 elements or 300 or more. As all ...