## javascript: compare with arrays of objects and update the key in Angular 6, Typescript

``````listOne: [
{
id: 1,
compId: 11,
active: false,
},
{
id: 2,
compId: 22,
active: false,
},
{
id: 3,
compId: 33,
active: false,
},
]

list two [
{
id: 1,
compId: 11,
active: true,
},
{
id: 2,
compId: 33,
active: false,
},
]
``````

I have two json, here how to compare with compId key and update the active key in listOne since list two .

In AngularJs I have tried with this link for AngularJs

But how to integrate with Angular 6 with Typescript.
Thank you.

## postgresql – Arrays added with overlapping values

I have a table with the values ​​of id and cluster int like this in PostgreSQL:

``````eleven
1 2
2 2
2. 3
3. 4
``````

Each ID can belong to several clusters and each cluster can cover several IDs.
How can I group by both columns to obtain this result?

``````[1,2] [1,2,3]
[3]   [4]
``````

I have managed to group only one column so far

``````with t as (select "unesto" (matrix[1,1,2,2,3]) id, unnest (array[1,2,2,3,4]clst)
select array_agg (id) id, array_agg (clst) of group t by id
``````

## the unit – instantiate with arrays of objects and transformations

The main errors here are:

1. Do not create your matrix with `cubeCree = new GameObject[2,3];` Before trying to assign content. Always make sure you have created the matrix with the proper dimensions before trying to use it; otherwise, you will get a null reference or an exception out of bounds.

2. Destroying the `initial cube` Object when your code will try to read it again the next time you press the "Q" key. Be sure to save the properties you will need and verify `null` Before trying to access the destroyed object.

3. Trying to use multidimensional arrays as public variables: the Unity Inspector will not allow you to initialize multidimensional arrays in that way.

The corrected code could look something like this:

``````public class ArrayInstanciar: MonoBehaviour {

// If what we want to work on are transformations, then store that reference directly.
Initial public transformation;
public Transform cubePrefab;

public float moveSpeed ​​= 5f;

// Private variables for the content that we complete at runtime.
Transform[,] cubes;
Vector3 originPosition;
Origin of the quaternion Rotation;

void Home () {
// Initialize the matrix before we try to use it.
// Note that the matrices are based on 0, so if later we want to access [1, 2],
// that means we need at least a 2x3 matrix (that is, {0, 1} x {0, 1, 2})
cubes = new transformation[2,3];
}

null Update () {
if (Input.GetKeyDown (KeyCode.Q)) {

// Capture the transformation of our reference object before we delete it.
if (cubeInitial! = null) {
originPosition = cubeInitial.position;
originRotation = cubeInitial.rotation;
Destroy (cubeInitial);
cubeInitial = null;
}

// Create an instance of our cube instances using the prefab.
cubes[1, 1] = Instanciar(cubePrefab, originPosition, originRotation);
cubes[1, 2] = Instanciar(cubePrefab, originPosition, originRotation);
}

// If you want these objects to move with time, then do not
// place the call Translate () inside a block that is only executed
// when the player presses "Q". Move them in each frame.

floating step = Time.deltaTime * moveSpeed;

yes (cubes[1,1] ! = null)
cubes[1,1].Translate (step, 0, step, Space.Self);

yes (cubes[1,2] ! = null)
cubes[1,2].Translate (step, 0, -step, Space.Self);
}
}
``````

It is not clear to me why he has moved his cubes within the ArrayInstantiate class, nor why he is using only indexes [1, 1] Y [1, 2] out of its matrix, but I left this as it is in this version of the code. I recommend sizing the matrix so that it contains only the indexes it needs, and placing the cube movement in a separate script in the cubes themselves, so that you do not have to manage their continuous behavior from the script that generates them.

## 2D Arrays in Java – Computer Science Stack Exchange

Forgive me if this is a stupid question, but I am a beginner in java and our teacher does not explain it very well. I understand how to create a chessboard in java. This is the code that I am using.

``````int sqSize = 50;
int gridSize = 500;
int n;
In t[][]    Grid;

public vacuum configuration () {
size (500, 500);
noLoop ();
n = gridSize / sqSize;
grid = new int[n][n];
}

empty draw () {

for (int row = 0; row <n; row ++) {

for (int col = 0; col <n; col ++) {

hit (0);
if ((row% 2) == (col% 2))
{
filling (255, 0, 0);
rect (row * sqSize, col * sqSize, sqSize-2, sqSize-2);
} else {
filling (0, 0, 0);
rect (row * sqSize, col * sqSize, sqSize-2, sqSize-2);
}
}
}
}
``````

Next, I'm supposed to put white circles on all the black squares so that it looks like a checker game. It does not have to move. As simple as that. I thought I would use the same logic I used with the rectangles, but then all the circles were far apart and did not match the black squares. Help?

## Lendo Json com muitos arrays com PHP

Boa afternoon to all give comunidade!

It is about dealing with PHP and not with the rest of the data of a certain variable, but also with the text and the null position.

``````                \$ url = & # 39; https: //api.hgbrasil.com/finance? format = json & # 39 ;;
\$ obj = json_decode (file_get_contents (\$ url), true);

print_r (\$ obj);
eco & # 39;& # 39 ;;
eco & # 39;& # 39 ;;
``````

esse e o Json returned, from já thanksço to ajuda de todos.

``````{"by": "default", "valid_key": true, "results": {"currencies": {"source": "BRL", "USD": {"name": "Dollar", "buy": 3.8732, "sell": null, "variation": - 1,078}, "EUR": {"name": "Euro", "buy": 4.3412, "sell": null, "variation": - 1.46}, " GBP ": {" name ":" Pound sterling "," buy ": 5.0878," sell ": null," variation ": - 0.611}," ARS ": {" name ":" Argentine peso "," buy " : 0.0905, "sell": null, "variation": - 0.11}, "BTC": {"name": "Bitcoin", "buy": 17082.794, "sell": 17082.794, "variation": 1.445}}, "stocks": {"IBOVESPA": {"name": "BM  u0026F BOVESPA", "location": "Sao Paulo, Brazil", "points": 96538.117, "variety": 1.18}, "NASDAQ": { "name": "NASDAQ Stock Market", "location": "New York, United States", "points": 7796.71, "variation": 0.87}, "CAC": {"name": "CAC 40", " location ":" Paris, French "," variation ": 1.03}," NIKKEI ": {" name ":" Nikkei 225 "," location ":" Tokyo, Japan "," variation ": 1.43}}," available_sources ":["BRL"], "bitcoin": {"blockchain_info": {"name": "Blockchain.info", "format":["USD","en_US"], "last": 4160.86, "buy": 4160.86, "sell": 4160.86, "variation": 1,445}, "coinbase": {"name": "Coinbase", "format":["USD","en_US"], "last": 4142.7, "variation": 1,537}, "bitstamp": {"name": "BitStamp", "format":["USD","en_US"], "last": 4142.95, "buy": 4142.83, "sell": 4141.33, "variation": 1.698}, "foxbit": {"name": "FoxBit", "format":["BRL","pt_BR"], "last": 16745.68, "variation": 2.72}, "mercadobitcoin": {"name": "Bitcoin Market", "format":["BRL","pt_BR"], "last": 16489.95994, "buy": 16400.0, "sell": 16489.95994, "variety": 1.227}, "omnitrade": {"name": "OmniTrade", "format":["BRL","pt_BR"], "last": 16250.0, "buy": 16250.0, "sell": 16610.0, "variation": 0.994}, "xdex": {"name": "XDEX", "format":["BRL","pt_BR"], "last": 16299.0, "variation": 1.154}}, "taxes":[{"date":"2019-03-29","cdi":6.4,"selic":6.4,"daily_factor":1.0002462}]}, "ecution_time": 0.0, "from_cache": true}
``````

## clojure – Use of deftype to create a container class for byte arrays

I want to create a container class for byte arrays to be able to use them as keys in `fastutil`is `Object2LongAVLTreeMap`. I created an envelope like this:

``````(Deftipo Bytes [^bytes ba]
Comparable
(compare with
[this other]
(leave [m (alength ^bytes (.ba this))
n (alength ^bytes (.ba other))
l (min m n)]
(tie [i 0]
(yes (<i l)
(leave [a (aget ^bytes (.ba ^Bytes this) i)
b (aget ^bytes (.ba ^Bytes other) i)
d (compare a b)]
(yes (zero? d)
(appeal (inc i))
re))
(compare m n))))))
``````

The wrap needs to implement `Comparable` For the inserts in the AVL tree.

I'm looking for comments on my general approach and my implementation of `compare with`. I will insert many entries in the tree, so I do not want to create unnecessary objects, etc. during the comparison.

## Algorithms – Superregular arrays – Computer Science Stack Exchange

Is there an efficient algorithm in practice (it is not necessary to be theoretically polynomial but can be implemented roughly for size matrices with n = 32 and size matrix ~ 20 × 100.) to verify if a matrix about $$mathbf {F} _ {p ^ n}$$ Is it superregular?

Superregular definition: a matrix is ​​superregular if all minors are not singular.

In particular, I am looking for a construction of block circulation matrices that are superregular.

## c #: is it better to have tracking fields that are maintained separately for arrays?

I was not sure exactly how to ask this question, but basically I have a `struct stNeuralLayers` (for a neural network with which I am playing) with fields that are matrices (like a `double[,] neural weights` field and a `double[,] results` field), and I have a field that is a matrix of those structures (`night readers[] fayNeuralLayers`).

The way I originally wrote it was that it had separate fields in the class (not the structure) that were kept separate, as `In t[] fwpightsPerNeuron` (which would store the number of weights per neuron for each layer as a matrix for the corresponding field) with the corresponding read-only property `In t[] NumWeightsPerNeuron` What would return a clone of the field.

The reason for this is that in many places, I'm going through the weights and accessing `fwpightsPerNeuron[i]` in a statement like `for (int j = 0; j <fldWeightPerNeuron[i]; j ++)` I think it's faster, especially if you also go through all the layers with `for (int i = 0; i <numLayers; i ++)` (`NumLayers` It is also a `In t` field that is maintained separately).

Obviously, the cost of this is the code required to maintain those fields when something is updated, so I mean the idea of ​​simply getting rid of the fields and creating read-only properties that only capture the necessary data directly (such as `public int weightPerNeuron {get {return weight.GetLength (1); }}` directly in the structure itself). I think the cost of doing so is that if I use those properties directly in loop declarations, performance will decrease (since accessing the GetLength () method is becoming slower than accessing only one element of a matrix at a time). You could also create temporary variables to store that data (such as `In t[] weightPersNeuron = fldNeuralLayers.Select (x => x.weights.GetLength (1)). ToArray ();` within the method for each method that would need it, but that is simply replacing one set of code (the code to keep fields separate) with another set of codes (the code to declare those variables and create the matrices to assign them within the various methods) .

Is there a best practice for this?

## Record arrays

I would like someone to explain to me about the registers, how they are used, syntax, etc. Since I have searched and is not much what I find on the subject, and also if they could explain me some operations with arrays of registration