4,457 questions
-2
votes
2
answers
126
views
Blackhole assignment in R [duplicate]
Suppose I have the following:
df1 <- data.frame(id=c(1,2,3))
df2 <- data.frame(id=c(2,3,4))
I want to print: (1) The number of IDs in df1 but not in df2, (2) the number of IDs in df2 but not in ...
-4
votes
1
answer
90
views
COBOL assignment debugging [closed]
Here is the prompt for my class assignment:
Create an interactive program for ice cream sales you must sell at least four flavors of ice cream and you must us an evaluate statement. The ice cream ...
3
votes
2
answers
122
views
Is there any way to move a string into a variable?
I was playing around in assembly and noticed that it's possible to overwrite a string in a variable as long as the new string does not exceed the size of the original string:
MESSAGE DB 'Hello World', ...
5
votes
0
answers
142
views
Under what circumstances does the Visual Studio compiler issue warning C4706 about assignment used as a condition?
My colleague Zag found that warning C4706: assignment used as a condition is detected by MSVC with /Wall switch only for some expressions and not for others.
In the following example:
#include <...
1
vote
1
answer
183
views
Understanding the difference between ??=, ?= and = for bitbake variables
When looking up something in the Yocto project reference manual, I sometimes encounter ??= or ?= operators. Normally, a simple = is used in recipes instead.
What's the difference between ??= and a ...
0
votes
6
answers
477
views
Why are the values of expressions independent of variable changes?
For example, there is a code:
#include <stdio.h>
int main(void)
{
int n = 54;
int index = 2 * n;
printf("%d\n",index);
n++;
printf("%d\n",index);
...
-2
votes
2
answers
143
views
How to read multiple lines into variables with a single read-command?
I need to read a three-line text like:
4
10
foo
into three variables: num1, num2, name.
I tried IFS=$'\n' read num1 num2 name <<< $data, but that only initializes the num1, leaving the rest ...
2
votes
1
answer
86
views
Error: Invalid dot name structure assignment because the structure array is empty
I'm having this error but I don't understand why. I'm creating a structure of size 3x4x4 with 6 fields within loops. Then, I would like to create two more fields for the whole structure. How can I do ...
13
votes
5
answers
2k
views
How Does the Left-Hand Side (LHS) of an Assignment Evaluate in C?
I’m working on understanding pointers in C by breaking down the language into three key areas: syntax, semantics, and idioms.
To grasp pointers, I’ve been focusing on fundamental concepts:
what’s an ...
0
votes
0
answers
48
views
Read CSVs and assign to variable name using for loop in R [duplicate]
I downloaded 11 years of reports from a government website and they each came in their own folder in a parent directory. The name of each subfolder is the year, and the file inside is named the same ...
0
votes
0
answers
33
views
Referring to the variable being assigned to on the right side of the assignment operator
Sometimes it may be necessary (yes, likely against best practices) to deal with nested objects, such as lists, which can require multi-level indexation. I am curious of the following:
1. In Python, is ...
1
vote
3
answers
131
views
How do I guarantee the rust compiler that a certain variable will get initialized in a for loop?
This question is in relation to the question asked here: How to declare a variable but not assign it?
My problem is slightly different. MRE:
let var: MyGenericType;
for value in ...
0
votes
2
answers
213
views
My C code works fine but crashes right before the end (0xC0000374)
So I'm learning to code (in C) for a few months now and I'm focusing here on memory allocation.
My code is very simple, everything works, and yet at the end, it doesn't return a 0 but instead I get a -...
0
votes
0
answers
39
views
Passing Nginx Rewrite To PHP
I've created the following Nginx Rewrite:
rewrite ^/([0-9A-Za-z]*)$ /index.php?redirect_reference=$1;
Then in my index.php I have:
<?php
echo $redirect_reference . "\r\n";
...
1
vote
1
answer
89
views
APL selective assignment with commute
Selective assignment (with replicate on the left) works as expected:
d←'bob'
(1 0 0/d)←'B'
d
Bob
But the same thing (though expressed with a commute) does not:
d←'bob'
(d/⍨1 0 0)←'B'
...
1
vote
2
answers
194
views
Are assignments from .Net methods atomic when stopping PowerShell?
Consider the following code which opens a file for writing in a job, stops that job, then opens the same file for writing again:
$filePath = [system.io.path]::GetTempFileName()
$job =
Start-...
0
votes
1
answer
78
views
Setting string variable after an if statement
After I set a string variable in an if() statement, the variable does not exist.
if (wallThicknessCBO.SelectedItem.ToString() == "2x6")
{
if (wallH <= 8)
{
MessageBox.Show(...
0
votes
1
answer
68
views
Is it possible to have a variable inside a for loop named exactly as the variable in the loop header?
I am a little confused regarding the assignment statement inside the code block of a for loop.
EXAMPLE CODE:
my_list = ['1', '2', '3', '4']
my_new_list = []
for element in my_list:
element = int(...
1
vote
2
answers
102
views
Getting the name of the variable assigned to a new variable in R [closed]
Suppose I do the following
y <- c(1,2,3)
x <- y
Now I want to know what variable was used in the assignment of x. I want it to return "y". Any idea how to do that?
3
votes
2
answers
150
views
Issues when parallelizing for loop to perform array assignments
I am learning omp and came across this issue...
consider following code where:
Arrays a, b, and c are initialized
#pragma omp parallel num_threads(4)
{
#pragma omp for schedule(static, 64)
...
0
votes
4
answers
132
views
Batch file argument that may be passed as integer
I try to write a batch script comparing the input with 2 integers and if it's in their range, the value is assigned to a variable. The other string parameters can be also passed as an argument so I ...
1
vote
0
answers
91
views
What are valid assignment targets in Python?
In Python, obviously it's possible to assign to names, e.g. a = 1. It's also valid to assign to attributes (a.b = 1 - AFAIK this corresponds to the __setattr__ special method) and indexing operations (...
0
votes
1
answer
45
views
Why is in-place assignment slower than creating a new array in NumPy?
I am trying to optimize a code, which has allocations inside a function that is repeatedly called in a loop. I ran some performance tests using jupyter and results were counterintuitive for me. As a ...
2
votes
1
answer
80
views
Trying to change a value from inside a function but it doesn't change when I exit the function
Trying to make a barebones Pokemon game and switching wont work
When trying to switch Pokemon I can get the code to recognize activePlayerMon= has had a value switch when running through the ...
0
votes
0
answers
29
views
Cin causes the value of a variable to change unexpectedly [duplicate]
So I am following this book Programming: Principles and Practice Using C++ 3rd edition and in section 2.3 Author gives the following code:
cout << "Please enter your first name and age\n&...