Questions tagged [assign]

Something related to an assignment operation, i.e. the process of changing the content of a variable to reflect some given value.

1695 questions
16
votes
1 answer

Assigning values in Verilog: difference between assign, <= and =

I have just started learning Verilog and I've seen these three lines from different sources. I am confused about the difference between the three: c <= a&b; assign c = ~a; c = 1'b0; These lines seem to assign a value to c but what's the…
dringx
  • 163
  • 1
  • 1
  • 5
16
votes
3 answers

Assign a column of a data.frame with string name in R

I am trying to assign data to an existing dataframe with a name generated in a loop. A basic example might be A = data.frame(a = c(1,2,3), b=c(3,6,2)) for (i in 1:2){ name = paste("Name",i, sep="") assign(name, c(6,3,2)) } Now I just need…
mmann1123
  • 5,031
  • 7
  • 41
  • 49
15
votes
2 answers

Can't assign this in constructor

I'm trying to merge the props from values into this. The following throws an error. How can I do this? this = {...this, ...values}
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
15
votes
1 answer

STL - assignment operator vs. `assign` member function

vector (as well as list and other containers) has a member function (MF) assign. I want to compare the assign MF (range version) vs. the assignment operator. As far as I understand it is useful to use assign when: One wants to assign a sub-range of…
YAKOVM
  • 9,805
  • 31
  • 116
  • 217
14
votes
4 answers

Why doesn't assign() values to a list element work in R?

I'm trying to use assign values in an object in a list. What I want to do is change some elements. For example: x <- list() x$test <- 1 assign("x$test", 2) x$test == 1 [1] TRUE Any thoughts? I need to use assign because I am building a…
mike
  • 22,931
  • 31
  • 77
  • 100
14
votes
2 answers

How can I set the text widget contents to the value of a variable in Python/Tkinter?

I am writing a program to assist with a trivial part of my job that can be automated. My purpose here is to: Copy and paste a chunk of plain text into a Tkinter text widget Use that pasted chunk of text as the value of a variable so that the…
Jaiden DeChon
  • 353
  • 1
  • 3
  • 13
14
votes
6 answers

In C, why can't I assign a string to a char array after it's declared?

This has been bugging me for a while. struct person { char name[15]; int age; }; struct person me; me.name = "nikol"; when I compile I get this error: error: incompatible types when assigning to type ‘char[15]’ from type ‘char *’ am…
Kok Nikol
  • 307
  • 1
  • 3
  • 9
13
votes
4 answers

Is there an immutable version of Object.assign?

I want to mix two objects in JavaScript: let a = {x: 1, y: 2, z:3}; let b = {x:10, y: 20}; let c = Object.assign(a, b); This gives the correct value for c: Object { x: 10, y: 20, z: 3 } But now a has been modified too! Object { x: 10, y: 20, z:…
sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
13
votes
1 answer

Why does `mylist[:] = reversed(mylist)` work?

The following reverses a list "in-place" and works in Python 2 and 3: >>> mylist = [1, 2, 3, 4, 5] >>> mylist[:] = reversed(mylist) >>> mylist [5, 4, 3, 2, 1] Why/how? Since reversed gives me an iterator and doesn't copy the list beforehand, and…
Stefan Pochmann
  • 27,593
  • 8
  • 44
  • 107
12
votes
2 answers

Assign Value to Diagonal Entries of Matrix

I need to access and assign single slots of an m*n matrix inside a for loop. The code so far: rowCount <- 9 similMatrix = matrix(nrow = rowCount - 1, ncol = rowCount) show(similMatrix) for(i in (rowCount - 1)){ for (j in rowCount) if (i ==…
DI MI
  • 245
  • 2
  • 5
  • 16
11
votes
1 answer

Re-assign unique values - pandas DataFrame

I am trying to assign unique values in pandas df to specific individuals. For the df below, [Area] and [Place] will together make up unique values that are various jobs. These values will be assigned to individuals with the overall aim to use the…
user9394674
11
votes
1 answer

Assign (or copy) column classes from a dataframe to another

I produced a large data frame (1700+obs,159 variables) with a function that collects info from a website. Usually, the function finds numeric values for some columns, and thus they're numeric. Sometimes, however, it finds some text, and converts the…
PavoDive
  • 6,322
  • 2
  • 29
  • 55
10
votes
3 answers

How to assign xml content to a string explicitly

Do you know how I can explicitlyt assign xml content to a string ? Example : string myXml = " Tove Jani Reminder Don't forget me this weekend! " I want to…
mathinvalidnik
  • 1,566
  • 10
  • 35
  • 57
9
votes
1 answer

How do I handle/circumvent "Cannot assign to ... which is behind a & reference" in Rust?

I'd implementing a simple linked list. This is the (working) code I had so far: pub struct LinkedList { start: Option>>, } impl LinkedList { pub fn new() -> LinkedList { return LinkedList { start: None }; …
Islion
  • 111
  • 1
  • 6
9
votes
1 answer

different results for standard form and functional form of data.table assigne-by-reference `:=`

There seems to be a minor difference between data.tabel's assignment by reference := in the standard to the functinal form. Standard form coerces RHS to vector, the functional form does not. A detail, but not documented as I…
rluech
  • 606
  • 4
  • 15