Questions tagged [variable-names]

256 questions
2
votes
5 answers

how much memory is allocated for a variable?

Possible Duplicate: Whether variable name in any programming language takes memory space I was just reading about memory allocation, and can't help wonder this question: Do both int x = 4; and int…
Prasanth
  • 5,230
  • 2
  • 29
  • 61
1
vote
3 answers

What is a good name for chosen actions, possibly in the past?

In my game, there is are ActionFactory (makes AbstractActions), AbstractAction (actions that could exist), PotentialAction (actions that a being could do, which are assosietted with a specific being) classes. I need a name for a class that…
technillogue
  • 1,482
  • 3
  • 16
  • 27
1
vote
3 answers

How to give readable names to elements of an array in C?

I'm inexperienced with C, and working on a microcontroller with messages stored in arrays where each byte does something different. How do I give each element of the array a human-readable name instead of referencing them as msg[1], msg[2], etc.? …
endolith
  • 25,479
  • 34
  • 128
  • 192
1
vote
1 answer

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 or __loc__ (Unix shell quoting issues?) at…
jonseymour
  • 1,006
  • 1
  • 12
  • 22
1
vote
1 answer

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 = { Red: 'Red', Green: 'Green', …
Nor.Z
  • 555
  • 1
  • 5
  • 13
1
vote
2 answers

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?
scissors127
  • 21
  • 1
  • 6
1
vote
1 answer

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 without having to write several lines. I have a…
Javiera
  • 11
  • 1
1
vote
1 answer

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() with open(thisdoc_dir + '/' +…
Fred Zimmerman
  • 1,178
  • 3
  • 13
  • 29
1
vote
1 answer

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, no symbols). I want to sort these strings by…
Dee G
  • 133
  • 9
1
vote
1 answer

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 code as a trial. library(Dict) x = c(1,2) d =…
Lei Zhang
  • 13
  • 2
1
vote
2 answers

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 string(e.g., df1_timediff) that I have assigned to it…
Aepkr
  • 101
  • 8
1
vote
2 answers

In python, is it best practice to always name your returned value?

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, number_2): "Adds two numbers." return number_1 +…
Jon Strutz
  • 302
  • 4
  • 9
1
vote
1 answer

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,1,1), pet_llama=c(1,1,1)) person pet pet_cat pet_dog pet_llama 1…
bill999
  • 2,147
  • 8
  • 51
  • 103
1
vote
1 answer

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, just cannot seem to find…
Samuel Saari
  • 1,023
  • 8
  • 13
1
vote
1 answer

How to use a word (title of a variable in a df) as an input in a function? (r)

Say I have this as my dataframe: library(fpp3) df <- prices And I want to create a function where I pass in the variable name and the number of steps forward I want to forecast. This is the function I have tried, which does not work. (I…