261 questions
9
votes
1
answer
545
views
variable name change causes segfault (datatype same name as the variable, used with malloc)
Okay it probably doesn't. That would be weird. I'm guessing, I'm allocating my memory wrong somehow.
#include <stdio.h>
#include <stdlib.h>
/*I have two Structs. In one there is a pointer ...
1
vote
1
answer
87
views
How do I change the names of thousands of variables in SPSS?
I have two SPSS datasets (a & b) that have identical variable names (eg. date, time, etc.). I want to combine them without confusion. Therefore, I want to change the variable names to reflect the ...
2
votes
2
answers
144
views
How to send an array from a text field of HTML form and sum its values? [duplicate]
I have 24 consecutively numbered variables whose sum I need to evaluate:
if($t1 + $t2 + $t3 + $t4 + $t5 + $t6
+ $t7 + $t8 + $t9 + $t10 + $t11 + $t12
+ $t13 + $t14 + $t15 + $t16 + $t17 + $t18
+...
0
votes
1
answer
63
views
How do I access dynamically created objects and their properties in JavaScript?
If I write a function that creates a new person and attach it to an onClick event on a button, how can I access the data that was entered without a variable name?
When a user presses the button, the ...
1
vote
1
answer
67
views
SPSS: Create a variable which reports the variable name of the MAX function
I need to create a variable in SPSS, that looks at a series of variables for the maximum value for each case, but reports the variable name (rather than the actual figure).
I know I can use the MAX ...
2
votes
0
answers
76
views
Assembly, gdb duplicate names
Let's assume we have defined a global non-initialized variable named f in C code.
Considering that, we would make label named f in the Assembly representation and put it in the .bss section.
The ...
0
votes
2
answers
56
views
How to document that a name of a variable can be different in another taxonomy?
For example, the taxonomies for community chat in Discord and Messenger are different, but they serve the same functionality:
Discord
Messenger
Server
Community
Text Channel/Forum Channel
Community ...
1
vote
1
answer
101
views
Is it possible to set variable as part of other variable's name [duplicate]
I have summarized data of many kinds of fruits like apple, melon, orange, pear, grape,... etc.
My code below works ok, but I like to make it template if possible.
<?php $fruit_name='apple' ?>
&...
1
vote
1
answer
632
views
How to preserve Unicode characters in name when bundling with esbuild?
In test.ts I have:
const π: number = 3.14
Running esbuild .\test.ts I get:
const \u03C0 = 3.14;
Is there a way to keep the variable name as π? Likewise for function names, class names, types, ...
2
votes
1
answer
96
views
Why can't $module be used as a variable name in jq?
Is this behaviour of jq, w.r.t the non-allowed use of $module as a variable name, specified anywhere?
$ jq -n --arg 'module' 'X' '$module'
jq: error: syntax error, unexpected module, expecting IDENT ...
0
votes
0
answers
32
views
Create a variable wita another variable in the (variable) name, and have a dynamic variable [duplicate]
naam$var='value' doesn't work
Need to use it in a loop : naam$var=$(sed -n $var"p" namefile.txt)
Dynamic variable names in Bash doesn't do the trick for me. Maybe i didn't understand it ...
0
votes
1
answer
119
views
Angular Validator requiredFalse
I want to add a validator to my FormControl that validates the form if a boolean is false.
There is requiredTrue but I need the opposite. Is there a validator for requiredFalse?
this.myForm.controls....
-1
votes
2
answers
278
views
How to get the original name of loop variables in JavaScript?
In the following example code, the function "getOriginalName" does not exist, but that is what I am looking for:
for(let variable of [var1, var2, var3]) {
console.log("Value: " ...
0
votes
1
answer
173
views
Naming variables which represent json
I am naming a variable JsonArray versionsJA = jsonObject.get("versions").getAsJsonArray()
Is there any proper naming convention that can be done here? I mean something better than the name ...
0
votes
1
answer
43
views
Create Dictionary with name and value of list of variables
I have a list of variables in python. And I want to create a dictionary whose key will be the name of the variable and the value will be the content.
a,b,c = 1,2,3
list = [a,b,c]
dic = {f'{item=}'....
0
votes
0
answers
51
views
Issues with naming empty dictionaries on Python
I was attempting to make an empty dictionary and use set default to allow duplicates. For some reason, the only variable name that would work is “d1”. Is there a reason why? I had another friend with ...
1
vote
1
answer
154
views
How to set an object property value to its own variable name (during initialization if possible)?
question
How to set an object property value to its own variable name (during initialization if possible)?
eg
For example, to create a Enum (inside class AA) in Javascript:
class AA {
static Color = ...
0
votes
1
answer
695
views
Naming conventions. Method or variable names containing numbers as a words
I can't find even couple of words about containing numbers in names of variables or on methods. Does anyone have any authoritative information about such cases:
string2map
its4me
etc...
Exactly using ...
0
votes
2
answers
273
views
variable with spaces in plotly
I know it is not ideal to have variable names with spaces. But I am curious if there is a way to do this for plotly in python easily.
So this worked for variables without spaces:
fig_gender = px.bar(
...
1
vote
1
answer
3k
views
How do you dynamically create useState variables in React?
I am working on a React application that is essentially a virtual library of books. Users are able to view shelves that show what they are currently reading, have already read, want to read, etc.
As ...
0
votes
1
answer
34
views
How to add name to vector before creating a dataframe of means sorted by group and variable
Thanks for looking at this!
I want a function to build tables showing stats, such as the mean) for specific variables segrgated into groups.
Below is a start of a function that works up to a point! I ...
1
vote
2
answers
11k
views
Can I change variable name in Python
Can I change my variable name in Python? For example, I have a string x, and I want to change string x variable name to y, how can I do it?
1
vote
1
answer
82
views
Column sum changing name of variables in r
I´m trying to do a column sum using apply and I would like to know if you could give me some advice to understand the best way to repete the same opperation but changing the names of the variables ...
0
votes
0
answers
120
views
Set an argument of a function as the name of a global variable defined within a function in R
I would like to set a functions argument as the variable name of a global variable defined within a function.
The reason is to create a general function which, connects to a database downloads data ...
0
votes
2
answers
495
views
How to return specific variable by passed variable name flutter?
I have levels screen and I want when I press on level 1 for example I want to get the list of level 1
is there a way to get it without using if or switch just like by passing the name of the list then ...
0
votes
1
answer
145
views
Variable names incompatible between SPSS and SAS
I imported an SPSS (.sav file) into SAS. Several of the variables are not showing up as they are named things like 'variable___1.1' When i try to KEEP certain variables in a data step, I get an error ...
2
votes
0
answers
658
views
Why are events written as $event in Angular?
I'm an Angular beginner, and during the course of learning Angular, various tutorials and websites have used naming conventions that declare events as $event as shown in below snippet:
@HostListener('...
1
vote
1
answer
361
views
is it safe to use the same variable name repeatedly in a series of functions?
Is it safe to re-use the same variable name repeatedly in a series of functions? My code is:
with open(thisdoc_dir + '/' + 'metadata.txt', 'w') as m:
m.write(str(metadatas[1]) + '\n')
m.close()...
0
votes
0
answers
370
views
Initialize member string with class object name in C++?
Is there a way to instantiate an object and have a string member take the object's name? I would also not mind for a gcc builtin.
Here's an example:
#include <string>
class A
{
std::...
2
votes
1
answer
646
views
Variable with same name with a struct type compiling only if it's not a template
Why is it allowed to have a variable with same name with a struct type only if it's not a template?
Why is this considered okay:
struct Foo {
int func(int) const;
};
struct Foo Foo;
but not this:...
0
votes
1
answer
1k
views
How do I change the value of one variable based on the value of another variable?
I have two variables. One categorical one with labels that take values 1-7. The value 7 indicates "other"
The other variable is the text that represents that "other".
col1 col2
1 ...
0
votes
0
answers
10
views
How can manipulate different variables with similar names in a for loop in r? [duplicate]
I have 9 data frames here, data01 to data09. My question is, how to get the column names of each data frame using for loop in r? The paste syntax didn't work.
for (i in 1: 9) {
print(colnames(paste(&...
0
votes
1
answer
378
views
Php: check if variable value exist as a variable || make variable value a variable
Is it possible to check if a variable exist using a variable value?
Like
//some variables:
$variable_a;
$variable_b;
$variable_c;
$variable_d;
$variable = '$variable_b';
if (the content $...
-1
votes
1
answer
594
views
What is a good name for a buffer for buffer overflow? [closed]
I'm not sure if this is this right place to ask this question, so please migrate this post to a correct place if it suits better.
I was really wondering what is a correct name for this.
char buf[SIZE +...
1
vote
2
answers
476
views
R - Appending to lists with names l_A, l_B, l_C ... etc. using for loops and built-in LETTERS
I've generated empty lists corresponding to every letter of the alphabet. The names of the lists take the form l_A, l_B, ...
I also have a one-column data frame populated with strings (all lowercase, ...
0
votes
1
answer
988
views
Insert variable name into a string dynamically
Let's say I have a string like this:
s = "blah blah start=0 length=10"
and i have two variables named start = 0 and length = 100.
Now, I want to form a new string (or replace the existing ...
1
vote
1
answer
735
views
How to use character as variable name in arguments? [R]
I am wondering how to tell R the string I used in the arguments of a function stands for a variable instead of the string itself. Specifically, I am dealing with 'Dict' package and run the following ...
1
vote
2
answers
697
views
For loop with dplyr pipeline: problem using dynamic and date variables correctly
I have the below code and example data. I have two issues:
The name of the new variable created using mutate appears as "New_var" in the corresponding data frames rather than the character ...
1
vote
2
answers
823
views
In python, is it best practice to always name your returned value? [closed]
For example, consider the following two functions:
Case 1
def add(number_1, number_2):
"Adds two numbers."
result = number_1 + number_2
return result
Case 2
def add(number_1, ...
3
votes
2
answers
2k
views
Dynamic array name in bash
Because bash doesn't support "arrays in arrays",
I'm trying to dynamize variable name when calling arrays.
bash version : 4.2
I used this expansion method: https://stackoverflow.com/a/...
0
votes
1
answer
747
views
R: How do I loop through a list of variables and create new ones with dynamic names?
I've been searching for hours now and I can't find a good example for what I want to do. I know how to do this in SAS easily but I'm newer to R. I have the code below that creates two variables. I ...
0
votes
1
answer
774
views
Changing variable names in R based on key in another dataframe
Suppose I have a dataset in R with variables named dog cat and cow. Then there are some number of values under each variable (ie. each is =1 if the respondent owns one and =0 if they don't):
...
1
vote
1
answer
475
views
How to check condition based on a variable match
Say that I have these data:
data <- tibble(person=c("Jack", "Jill", "Bill"), pet=c("dog", "cat", "zebra"), pet_cat=c(0,1,0), pet_dog=c(0,...
0
votes
2
answers
160
views
How to select a variable by a substring with JavaScript
I have more than 10 javascript variables which change every time the page is refreshed.
I would like to select this variable:
var layer_control_e69649c5e9f941908fcc3173d4dee734 = {
base_layers: {},
...
0
votes
1
answer
4k
views
Change the values of an object's properties, depending on the property's name
I would like to change the value of targeted properties within my object depending on the property's name.
Example:
// Returns a list of all the properties of an object
PropertyInfo[] properties = ...
0
votes
0
answers
99
views
How to identify the varname from an OLS fit summary?
This is a model for MLB, and to my understanding each var name (x1,x2,x3...) should be associated with a pitcher name. How can I identify which pitcher is associated with the var name?
...
-1
votes
1
answer
251
views
Is there a Python function for creating variables? [duplicate]
I am doing a python project in which I want to create several variables that all hold the same information; however, I cannot figure this out on my own.
Instead of writing:
a = 1
b = 1
c = 1
and so ...
-2
votes
1
answer
1k
views
What is the 'ctr' variable in a parallel C# loop? [duplicate]
I recently used a Parallel.For loop (see code below) in a small C# program and I'm a little perplexed by the ctr variable. Every example I've seen so far has the name of this variable set to ctr, but ...
1
vote
1
answer
246
views
Extracting parameter names in nested functions in R
I would like to extract the name of a function parameter as a string.
It works fine unless the function is called from within another function (see below).
There must be a simple solution for this, ...
0
votes
1
answer
1k
views
How to extract the name of a variable in a Python function [duplicate]
I have a custom Python function that uses the input of a model to create a data frame of the predicted y-values, probabilities, and some other features. I am trying to extract the physical variable ...