# Tag: variables

## bash – After set up environment variables my pyspark fail in ubuntu

I installed pyspark from anaconda like

```
$ conda install pyspark
```

after that in my jupyter notebook it works fine, but in the tutorial

https://mortada.net/3-easy-steps-to-set-up-pyspark.html

is mentioned that you have to set up the environment variables like

```
$ export SPARK_HOME=~/spark-2.2.0-bin-hadoop2.7
$ export PYSPARK_PYTHON=~/anaconda/bin/python
```

When I tried to rerun pyspark in my jupyter notebook the next error appear

FileNotFoundError: (Errno 2) No such file or directory: ‘/home/jogabell/Documentos/programas/spark-2.4.7-bin-hadoop2.7/./bin/spark-submit’: ‘/home/jogabell/Documentos/programas/spark-2.4.7-bin-hadoop2.7/./bin/spark-submit’

My jupyter notebook look like:

```
from pyspark import SparkContext
sc = SparkContext(master="local(4)")
print(sc)
```

Help me to fix it, please.

## “Variable” variables in Javascript? – Stack Overflow

Unlike PHP, JavaScript doesn’t offer access to the globals array (which contains references to all the variable names currently declared). As such, JavaScript does not offer native support for variable variables. You can, however, emulate this feature as long as you define all your variables as part of an array or an object. This will in turn create a gloabls array for you. For example, instead of declaring the variable `hello`

in the global scope like this:

```
var hello = 'hello world';
```

let’s encapsulate it inside an object. We’ll call that object vv (variable variables):

```
var vv = {
'hello': 'hello world',
//Other variable variables come here.
},
referToHello = 'hello';
```

Now we can refer to the variable by it’s index, and since array indexes can be provided using a variable we are de facto making use of a variable variable:

```
console.log(vv(referToHello)); //Output: hello world
```

**The Answer To Your Question**

Let’s apply this to the code you supplied in the original question:

```
var vv = {
'x': 'variable',
'variable': 'hello world!'
};
console.log(vv(vv('x'))); //Displays "hello, world!"
```

**A Practical Use**

While the previous code might appear ridiculously cumbersome and impractical, there are practical uses for variable variables in JavaScript using this type of encapsulation. In the example below we use the same concept to get the ID of an undefined number of HTML elements.

```
var elementIds = (),
elements = ('message','fillOrStroke','sizePicker','colorPicker'); //The items in this array could be defined automatically via an input, database query, event, etc.
elements.forEach( (element) => {
elementIds(element) = document.getElementById(element);
});
```

This example declares variable variables (keys in `elementIds`

) based on the ID of each element, and will assign the node of said element as the value of each variable. And since using global variables in JavaScript is generally discouraged giving your variable variables a unique scope (in this instance, declaring them inside the `elementIds`

array) is not only neat, but also more responsible.

## views – How to debug and find variables on twig themes

I’m trying to create a theme for a drupal web site, but I find it difficult to get variables.

Here is an example:

to get an image form a view I wrote this line

```
row.content['#row']._entity.field_image.entity.uri.value
```

How can we define this path ? even with **vardumper** and **dump** it’s not possible to get this information!!

Is there any effective way to determine how variables are structred ?

## programming languages – Dfferences in c++ about how variables are used in functions and when to use int

*I would want to know why code::blocks do not print the same thing if I write the next sequence of code:*

```
int n,m,a(11)(11),x(11),y,z,v(11),i;
int va(int k)
{
return a(x(k-1))(i) && !v(i);
}
int s(int k)
{
return i==y;
}
void t(int k)
{
for(int j=1; j<=k; j++)
cout<<x(j)<<' ';
cout<<endl;
}
void ck(int k)
{
for(int i=1; i<=n; i++)
if(va(k))
{
v(i)=1;
x(k)=i;
if(s(k))
{
t(k);
}
else ck(k-1);
v(i)=0;
}
}
```

*as when I write the following one:*

```
int n,m,a(11)(11),x(11),y,z,v(11),i;
int va(int k)
{
return a(x(k-1))(i) && !v(i);
}
int s(int k)
{
return x(k)==y;
}
void t(int k)
{
for(int j=1; j<=k; j++)
cout<<x(j)<<' ';
cout<<endl;
}
void ck(int k)
{
for(int i=1; i<=n; i++)
if(a(x(k-1))(i) && !v(i))
{
v(i)=1;
x(k)=i;
if(s(k))
{
t(k);
}
else ck(k+1);
v(i)=0;
}
}
```

*or the following one:*

```
int n,m,a(11)(11),x(11),y,z,v(11),i;
int valid(int k)
{
return a(x(k-1))(i) && !v(i);
}
int solutie(int k)
{
return i==y;
}
void tipar(int k)
{
for(int j=1; j<=k; j++)
cout<<x(j)<<' ';
cout<<endl;
}
void ck(int k)
{
for(i=1; i<=n; i++)
if(a(x(k-1))(i) && !v(i))
{
v(i)=1;
x(k)=i;
if(s(k))
{
t(k);
}
else ck(k+1);
v(i)=0;
}
}
```

## factorization – Can Mathematica factor multivariate polynomials with 4 or more variables? And with high degrees (>10)

The Mathematica documentation clearly states

the Wolfram Language routinely factors degree-100 polynomials in 3 variables

I’m interested in factoring systems of polynomials in as many as 10 or 20 variables. The systems I have are sparse in the sense that if there are 20 variables then likely no more than 3-6 variables will appear per equation and there will likely only be two terms per equation. I’ve used `Solve`

to test on some small systems with success. To be clear, we don’t actually need to factor the polynomials necessarily. If we factor them, then we have what we need. What we really want are the roots to the system with respect to the symbolic coefficients. `Solve`

worked for some small test systems. `Factor`

would also work for a single polynomial, but we need a system of polynomials and I don’t see that `Factor`

will take a system.

I’ve looked at papers by searching scholar.google.com and it seems our problem is a solved problem in mathematics. Algorithms seem to exist for such a problem, but I’m even unclear on this since the papers are too densely packed with math for me to easily understand.

Any help would be appreciated.

## unity – Iterating through an array to check if all variables have a certain value

Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.

Sign up to join this community

Anybody can ask a question

Anybody can answer

The best answers are voted up and rise to the top

Asked

Viewed

5 times

It could be very simple but im not seeing it.I want to iterate an array and check if each element has a certain value and if all of them have the same to do something, i tried it with a for loop like so:

```
(Serializable)
public class LevelData
{
(Header("Art Set"))
public int lastUnlockedLevel = 0;
public bool previewOpen;
public LevelItemArray() levelItemArray;
}
(Serializable)
public class LevelItemArray
{
public bool unlocked;
public int starAchieved;
}
public void CheckSet()
{
for (int i = 0; i < LevelData.levelItemArray.Length; i++)
{
if (LevelData.levelItemArray(i).starAchieved == 3)
{
LevelData.previewOpen = true;
}
else
{
LevelData.previewOpen = false;
}
}
```

but this way even if one of the starAchieved int is 3 it sets the previewOpen to true.

$endgroup$

1

lang-cs

## cv.complex variables – Gluing together holomorphic functions without Mergelyan theorem

Consider the unit ball $Delta={|z|<1}$ and a Lipschitz (meaning that it is the graph of some Lip. real function) segment, say $Gamma=(1,7)$.

Consider $f$ holomorphic in a neighborhood of the ball, for convenience we take $finmathcal O(Delta_4)$ and continuous on the whole plane $Bbb C$.

I want to approximate $f$ on $DeltacupGamma$ by entire functions.

Call $g$ the Taylor polynomial of $f$ centered in $0$ and truncated at a sufficiently high order: it is entire and approsimate $f$ on $Delta_4$ (the open ball of radius 4).

Call $h$ the entire function (provided by a theorem by P.Manne contained in his phd thesis, I cannot find online; the important part is that such a function exists) approximating $f$ on $Gamma$.

The problem is that we don’t know how does $g$ behaves on $Gamma$ and viceversa, we don’t know how does $h$ behaves on $Delta$.

Defining a smooth function $chi(z)$ to be 0 on $|z|<2,|z|>8$ and $1$ on $3<|z|<7$ and considering

$$

widetilde f = g+chi(h-g)

$$

this is continuous (and with compact support) on the whole plane and approximate $f$ on $DeltacupGamma$.

If allowed to use Mergelyan theorem I could approximate $chi$ with an entire function on $|z|<9$ and conclude, but I can’t.

Any hint on how to glue two entire functions without using Mergelyan thm?

## postgresql – How can I dynamically create views in Postgres 10 using variables?

You need dynamic SQL for this:

```
do $$
declare
myschema varchar(10) := 'SCHEMA1';
mywhere varchar(3) := 'ABC';
begin
execute format('
create or replace view %I.myview as
select * from SHAREDSCHEMA.sometable where MYCOL = %L', myschema, mywhere);
end $$;
```

The `format()`

function is highly recommended when creating dynamic SQL to properly deal with identifiers and constant values.

You can also put this into a function (or procedure in newer versions):

```
create function create_view(p_schema text, p_value text)
returns void
as
$$
begin
execute format('
create or replace view %I.myview as
select * from SHAREDSCHEMA.sometable where MYCOL = %L', p_schema, p_value);
end
$$
language plpgsql;
```

Then you can run:

```
select create_view('myschema', 'xyz');
```

If you want, you can use that to create all views in one go:

```
with data (schema_name, value) as
values
('schema1', 'abc'),
('schema2', 'def'),
('schema3', 'ghi')
)
select create_view(schema_name, value)
from data;
```

## ¿Cómo puedo agregar variables a mi cuerpo (Body) de email, si este es escrito en HTML y mi script en Python?

self.body = """Cordial saludo:

Se adjunta informe de recepcion de la planilla **self.ent5.get()** con placa **self.ent6.get()** recepcionado de la ciudad de **self.ent3.get()** el cual presenta:

```
"""
```