variable-assignment Questions
5
Solved
ksh has a really interesting construct to do this, detailed in this answer: https://mcmap.net/q/41292/-capture-stdout-and-stderr-into-different-variables
Since Bash 4.0, there is a builtin mapfile...
Latria asked 7/2, 2014 at 15:51
8
Solved
I have gone through these questions,
Python assigning multiple variables to same value? list behavior
concerned with tuples, I want just variables may be a string, integer or dictionary
More eleg...
Capitoline asked 25/10, 2015 at 15:58
11
Solved
I am trying to find the syntax that will allow me to set a variable to a specific value only if it wasn't previously assigned.
Basically I want:
# only if var1 has not been previously assigned
var1...
Socioeconomic asked 7/9, 2011 at 18:8
8
Solved
$a = $b = 0;
In the above code, are both $a and $b assigned the value of 0, or is $a just referencing $b?
Fail asked 6/6, 2011 at 19:42
13
Solved
import copy
a = "deepak"
b = 1, 2, 3, 4
c = [1, 2, 3, 4]
d = {1: 10, 2: 20, 3: 30}
a1 = copy.copy(a)
b1 = copy.copy(b)
c1 = copy.copy(c)
d1 = copy.copy(d)
print("immutable - id(a)==id(a1)", id(...
Tyus asked 22/6, 2013 at 2:15
13
Solved
import copy
a = "deepak"
b = 1, 2, 3, 4
c = [1, 2, 3, 4]
d = {1: 10, 2: 20, 3: 30}
a1 = copy.copy(a)
b1 = copy.copy(b)
c1 = copy.copy(c)
d1 = copy.copy(d)
print("immutable - id(a)==id(a1)", id(...
Renounce asked 22/6, 2013 at 2:15
13
Solved
import copy
a = "deepak"
b = 1, 2, 3, 4
c = [1, 2, 3, 4]
d = {1: 10, 2: 20, 3: 30}
a1 = copy.copy(a)
b1 = copy.copy(b)
c1 = copy.copy(c)
d1 = copy.copy(d)
print("immutable - id(a)==id(a1)", id(...
Rees asked 22/6, 2013 at 2:15
10
Solved
int matrix[9][9],*p;
p=matrix[0];
this works and gives first row of matrix, but how to get first column of matrix I've tried p=matrix[][0]; ? Also I don't understand why below code gets compiler...
Kelcey asked 6/3, 2013 at 21:7
6
Solved
I want to forbid further assignments on some attributes of a class after it was initialized. For instance; no one can explicitly assign any value to 'ssn' (social security number) property after th...
Medici asked 7/6, 2012 at 9:19
7
Solved
I found this problem in a GitHub front-end interview questions collection:
var foo = {n: 1};
var bar = foo;
foo.x = foo = {n: 2};
Question: What is the value of foo.x?
The answer is undefined.
I...
Emetine asked 2/9, 2015 at 0:16
6
Solved
In C#, if I have a List<T>, and I have an object of type T, how can I replace a specific item in the List<T> with the object of type T?
Here is what I have tried:
List<CustomListItem...
Brendabrendan asked 5/11, 2014 at 8:49
11
Solved
Why are assignment operators (=) invalid in a foreach loop? I'm using C#, but I would assume that the argument is the same for other languages that support foreach (e.g. PHP). For example, if I do ...
Nape asked 23/8, 2010 at 16:47
4
Solved
I have the following code:
var o = {};
o.a = 1;
var _value = 1;
Object.defineProperty(o,"a",{
set: function(value){
_value = value + 1;
console.log("log: ", value, _value);
return _value;
},...
Trinitytrinket asked 27/10, 2014 at 6:15
16
Solved
What's the easiest way to add an empty column to a pandas DataFrame object? The best I've stumbled upon is something like
df['foo'] = df.apply(lambda _: '', axis=1)
Is there a less perverse method...
Rozina asked 1/5, 2013 at 21:46
6
Solved
I have this script called test.sh:
#!/bin/bash
STR = "Hello World"
echo $STR
when I run sh test.sh I get this:
test.sh: line 2: STR: command not found
What am I doing wrong? I look at extreme...
Swamp asked 15/2, 2010 at 18:32
5
Solved
why do the following lines not work as I expect?
import numpy as np
a = np.array([0,1,2,1,1])
a[a==1][1:] = 3
print a
>>> [0 1 2 1 1]
# I would expect [0 1 2 3 3]
Is this a 'bug' or is ...
Corallite asked 6/11, 2009 at 13:21
17
Solved
Still trying to get into the R logic... what is the "best" way to unpack (on LHS) the results from a function returning multiple values?
I can't do this apparently:
R> functionReturningTwoValu...
Selfpronouncing asked 1/12, 2009 at 14:27
2
Solved
Consider the following example illustrating the question (it was just built to explain the question, but I saw similar code in books as well in real projects):
package main
import (
"strconv"
"...
Esquire asked 14/12, 2015 at 11:50
2
Solved
Apologies if this is a stupid question - but this my first attempt at using R, and i have ended up writting some code along the lines of:
some <- vector('list', length(files))
thing <- vecto...
Herlindaherm asked 14/11, 2012 at 18:5
3
Solved
My code:
function test() {
let value: number;
for (let i = 0; i < 10; i++) {
value = i;
console.log(value);
}
return value;
}
test();
And got this:
Variable 'value' is used before bein...
Gold asked 19/11, 2021 at 2:59
3
Solved
I have been using the Locals window to check the assignments for procedure level variables.
I have recently updated my code to create a set of public-level variables that read certain inputs from ...
Fragonard asked 22/2, 2013 at 19:0
12
Solved
Until today, I thought that for example:
i += j;
Was just a shortcut for:
i = i + j;
But if we try this:
int i = 5;
long j = 8;
Then i = i + j; will not compile but i += j; will compile fi...
Natant asked 3/1, 2012 at 10:10
6
Solved
I'm initializing a lot of string variables as follows:
a, b, c, d, e, f, g, h = "", "", "", "", "", "", "", ""
You can see that this doesn't look very nice (morever the variables have longer name...
Youngman asked 27/1, 2012 at 14:25
10
Solved
Does R have a concept of += (plus equals) or ++ (plus plus) as c++/c#/others do?
Thereunder asked 21/4, 2011 at 2:25
2
Solved
How do you update multiple properties on a pydantic model that are validated together and dependent upon each other?
Here is a contrived but simple example:
from pydantic import BaseModel, root_val...
Disquiet asked 14/9, 2022 at 14:26
1 Next >
© 2022 - 2024 — McMap. All rights reserved.